Regular expression syntax corrections and enhancements:
\w | any word constituent character (equivalent to [a-zA-Z0-9_]) | ||
\W |
any character but a word constituent (equivalent to [^a-xA-Z0-9_] |
||
\d | a digit (same as [0-9]) | ||
\D | anything but a digit | ||
\s | a whitespace character | ||
\S | anything but a whitespace character | ||
\b | an empty string at a word boundary | ||
\B | an empty string not at a word boundary | ||
\< | an empty string at the beginning of a word | ||
\> | an empty string at the end of a word |
For example, '\w+' is now a valid expression matching any word.
\w, \W, \d, \D, \s et \S |
[:alnum:] | |
[:alpha:] | |
[:cntrl:] | |
[:digit:] | |
[:graph:] | |
[:lower:] | |
[:print:] | |
[:punct:] | |
[:space:] | |
[:upper:] | |
[:xdigit:] |
'[[:alnum:]]+' '\w+' '[\w]+' '[a-zA-Z0-9]+' |
\t | tab (Character tab) | ||
\n |
newline (Character lf) |
||
\r | carriage return (Character cr) | ||
\f | form feed (Character newPage) | ||
\e | escape (Character esc) |
#asRegexIgnoringCase, | |
#matchesRegexIgnoringCase:, | |
#prefixMatchesRegexIgnoringCase: |
matchesIn: aString |
|
matchesIn: aString collect: aBlock | |
matchesIn: aString do: aBlock | |
matchesOnStream: aStream | |
matchesOnStream: aStream collect: aBlock | |
matchesOnStream: aStream do: aBlock | |
copy: aString translatingMatchesUsing: aBlock | |
copy: aString replacingMatchesWith: replacementString | |
copyStream: aStream to: writeStream translatingMatchesUsing: aBlock | |
copyStream: aStream to: writeStream replacingMatchesWith: aString |
'\w+' asRegex matchesIn: 'now is the time' |
'\<t\w+' asRegexIgnoringCase copy: 'now is the time' translatingMatchesUsing: [:match | match asUppercase] |
Since the first release of the matcher, thanks to the input from several fellow Smalltalkers, I became convinced a native Smalltalk regular expression matcher was worth the effort to keep it alive. For the advice and encouragement that made this release possible, I want to thank:
Felix Hack | |
Eliot Miranda | |
Robb Shecter | |
David N. Smith | |
Francis Wolinski |
and anyone whom I haven't yet met or heard from, but who agrees this has not been a complete waste of time.
--Vassili Bykov
October 3, 1999
Updated on 2002-03-10