@@ -178,12 +178,12 @@ func (re *Regexp) ReplaceFunc(input string, evaluator MatchEvaluator, startAt, c
178
178
179
179
// FindStringMatch searches the input string for a Regexp match
180
180
func (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 ))
183
183
}
184
184
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 ) {
187
187
return re .run (false , - 1 , r )
188
188
}
189
189
@@ -192,17 +192,17 @@ func (re *Regexp) FindStringMatchStartingAt(s string, startAt int) (*Match, erro
192
192
if startAt > len (s ) {
193
193
return nil , errors .New ("startAt must be less than the length of the input string" )
194
194
}
195
- r , startAt := re .getRunesAndStart (s , startAt )
195
+ r , startAt := re .getBytesAndStart (s , startAt )
196
196
if startAt == - 1 {
197
197
// 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" )
199
199
}
200
200
201
201
return re .run (false , startAt , r )
202
202
}
203
203
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 ) {
206
206
return re .run (false , startAt , r )
207
207
}
208
208
@@ -233,44 +233,44 @@ func (re *Regexp) FindNextMatch(m *Match) (*Match, error) {
233
233
// MatchString return true if the string matches the regex
234
234
// error will be set if a timeout occurs
235
235
func (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 ))
237
237
if err != nil {
238
238
return false , err
239
239
}
240
240
return m != nil , nil
241
241
}
242
242
243
- func (re * Regexp ) getRunesAndStart (s string , startAt int ) ([]rune , int ) {
243
+ func (re * Regexp ) getBytesAndStart (s string , startAt int ) ([]byte , int ) {
244
244
if startAt < 0 {
245
245
if re .RightToLeft () {
246
- r := getRunes (s )
246
+ r := getBytes (s )
247
247
return r , len (r )
248
248
}
249
- return getRunes (s ), 0
249
+ return getBytes (s ), 0
250
250
}
251
- ret := make ([]rune , len (s ))
251
+ ret := make ([]byte , len (s ))
252
252
i := 0
253
- runeIdx := - 1
254
- for strIdx , r := range s {
253
+ byteIdx := - 1
254
+ for strIdx , r := range [] byte ( s ) {
255
255
if strIdx == startAt {
256
- runeIdx = i
256
+ byteIdx = i
257
257
}
258
258
ret [i ] = r
259
259
i ++
260
260
}
261
261
if startAt == len (s ) {
262
- runeIdx = i
262
+ byteIdx = i
263
263
}
264
- return ret [:i ], runeIdx
264
+ return ret [:i ], byteIdx
265
265
}
266
266
267
- func getRunes (s string ) []rune {
268
- return []rune (s )
267
+ func getBytes (s string ) []byte {
268
+ return []byte (s )
269
269
}
270
270
271
- // MatchRunes return true if the runes matches the regex
271
+ // MatchBytes return true if the bytes matches the regex
272
272
// 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 ) {
274
274
m , err := re .run (true , - 1 , r )
275
275
if err != nil {
276
276
return false , err
0 commit comments