[bug] String>>escapeRegex fails on Strings including an asterisk

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[bug] String>>escapeRegex fails on Strings including an asterisk

Tim Felgentreff
Issue status update for
http://smalltalk.gnu.org/node/394
Post a follow up:
http://smalltalk.gnu.org/project/comments/add/394

 Project:      GNU Smalltalk
 Version:      <none>
 Component:    STInST
 Category:     bug reports
 Priority:     normal
 Assigned to:  Unassigned
 Reported by:  timfelgentreff
 Updated by:   timfelgentreff
 Status:       active

gst-convert fails with "Invalid index 1: index out of range" when trying
to convert methods have a '*' in their category to squeak. The reason is
that since b44ebba00d36fe7a3d112811f4617f5630ee55f4 escapeRegex is
called on the methodCategory.

As 'escapeRegex' should simply put backslashes in Front of regex
characters, why not use a simple

 String>>escapeRegex [
    ^ '[][?*+\\()^$|]'
       inject: self
       into: [:str :char |
          str
             copyReplaceAll: char asString
             with: '\', char asString].
 ]

instead of the call to "copyFrom:to:replacingAllRegex:with:"? Wouldn't
that solve the problem?




_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk