@@ -178,12 +178,12 @@ func (re *Regexp) ReplaceFunc(input string, evaluator MatchEvaluator, startAt, c
178178
179179// FindStringMatch searches the input string for a Regexp match
180180func (re * Regexp ) FindStringMatch (s string ) (* Match , error ) {
181- // convert string to runes
182- return re .run (false , - 1 , getRunes (s ))
181+ // convert string to bytes
182+ return re .run (false , - 1 , getBytes (s ))
183183}
184184
185- // FindRunesMatch searches the input rune slice for a Regexp match
186- func (re * Regexp ) FindRunesMatch (r []rune ) (* Match , error ) {
185+ // FindBytesMatch searches the input byte slice for a Regexp match
186+ func (re * Regexp ) FindBytesMatch (r []byte ) (* Match , error ) {
187187 return re .run (false , - 1 , r )
188188}
189189
@@ -192,17 +192,17 @@ func (re *Regexp) FindStringMatchStartingAt(s string, startAt int) (*Match, erro
192192 if startAt > len (s ) {
193193 return nil , errors .New ("startAt must be less than the length of the input string" )
194194 }
195- r , startAt := re .getRunesAndStart (s , startAt )
195+ r , startAt := re .getBytesAndStart (s , startAt )
196196 if startAt == - 1 {
197197 // we didn't find our start index in the string -- that's a problem
198- return nil , errors .New ("startAt must align to the start of a valid rune in the input string" )
198+ return nil , errors .New ("startAt must align to the start of a valid byte in the input string" )
199199 }
200200
201201 return re .run (false , startAt , r )
202202}
203203
204- // FindRunesMatchStartingAt searches the input rune slice for a Regexp match starting at the startAt index
205- func (re * Regexp ) FindRunesMatchStartingAt (r []rune , startAt int ) (* Match , error ) {
204+ // FindBytesMatchStartingAt searches the input byte slice for a Regexp match starting at the startAt index
205+ func (re * Regexp ) FindBytesMatchStartingAt (r []byte , startAt int ) (* Match , error ) {
206206 return re .run (false , startAt , r )
207207}
208208
@@ -233,44 +233,44 @@ func (re *Regexp) FindNextMatch(m *Match) (*Match, error) {
233233// MatchString return true if the string matches the regex
234234// error will be set if a timeout occurs
235235func (re * Regexp ) MatchString (s string ) (bool , error ) {
236- m , err := re .run (true , - 1 , getRunes (s ))
236+ m , err := re .run (true , - 1 , getBytes (s ))
237237 if err != nil {
238238 return false , err
239239 }
240240 return m != nil , nil
241241}
242242
243- func (re * Regexp ) getRunesAndStart (s string , startAt int ) ([]rune , int ) {
243+ func (re * Regexp ) getBytesAndStart (s string , startAt int ) ([]byte , int ) {
244244 if startAt < 0 {
245245 if re .RightToLeft () {
246- r := getRunes (s )
246+ r := getBytes (s )
247247 return r , len (r )
248248 }
249- return getRunes (s ), 0
249+ return getBytes (s ), 0
250250 }
251- ret := make ([]rune , len (s ))
251+ ret := make ([]byte , len (s ))
252252 i := 0
253- runeIdx := - 1
254- for strIdx , r := range s {
253+ byteIdx := - 1
254+ for strIdx , r := range [] byte ( s ) {
255255 if strIdx == startAt {
256- runeIdx = i
256+ byteIdx = i
257257 }
258258 ret [i ] = r
259259 i ++
260260 }
261261 if startAt == len (s ) {
262- runeIdx = i
262+ byteIdx = i
263263 }
264- return ret [:i ], runeIdx
264+ return ret [:i ], byteIdx
265265}
266266
267- func getRunes (s string ) []rune {
268- return []rune (s )
267+ func getBytes (s string ) []byte {
268+ return []byte (s )
269269}
270270
271- // MatchRunes return true if the runes matches the regex
271+ // MatchBytes return true if the bytes matches the regex
272272// error will be set if a timeout occurs
273- func (re * Regexp ) MatchRunes (r []rune ) (bool , error ) {
273+ func (re * Regexp ) MatchBytes (r []byte ) (bool , error ) {
274274 m , err := re .run (true , - 1 , r )
275275 if err != nil {
276276 return false , err
0 commit comments