The following VWST code works fine, however in trying to convert to gst I cannot find much help
in changing the REGEX line of code. The problem is to extract all the integers from a text line and sort into order and print, and NO its not a class test :-), just a example of string manipulation from a C++ site I think. I've tried replaceAllRegex:with: and am getting a doesNotUndertstand error In the small extraction below I'm simply trying to get a regex to suppress ( replace) any alphas with a space -- without sucess !! ============= gst test ========================= | txt nums | Transcript cr; show: '*** hiddennumbers.ws '; show: Time now printString ; cr. txt := '098m03r9f80239802389f0m9KDKLKLJDKLJm0983m890DMOm03 dlkfj3hljf4h3klhl00000002998'. Transcript cr; show: txt ; cr. " // txt := txt copyWithRegex: '[a-zA-Z]' matchesReplacedWith: ' '. " " vwst code " txt := txt replaceAllRegex: '[a-zA-Z]' with: ' '. " gst code " " replace all alphas with space " Transcript cr; show: txt ; cr. ========================= execution ==================== $ gst -f hiddennumbers.st *** hiddennumbers.ws 15:38:46 098m03r9f80239802389f0m9KDKLKLJDKLJm0983m890DMOm03 dlkfj3hljf4h3klhl00000002998 Object: '098m03r9f80239802389f0m9KDKLKLJDKLJm0983m890DMOm03 dlkfj3hljf4h3klhl00000002998' error: did not understand #replaceAllRegex:with: MessageNotUnderstood(Exception)>>signal String(Object)>>doesNotUnderstand: #replaceAllRegex:with: UndefinedObject>>executeStatements 098m03r9f80239802389f0m9KDKLKLJDKLJm0983m890DMOm03 dlkfj3hljf4h3klhl00000002998 $ ================================================ |
dragoncity wrote:
> The following VWST code works fine, however in trying to convert to gst I > cannot find much help > in changing the REGEX line of code. > > The problem is to extract all the integers from a text line and sort into > order and print, and NO its not a class test :-), > just a example of string manipulation from a C++ site I think. > > I've tried replaceAllRegex:with: and am getting a doesNotUndertstand error #replacingAllRegex:with: is the name of the selector. You can also use #allOccurrencesOfRegex:. Paolo _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
Using the correct selector just might help !! :-)
==================================================== *** hiddennumbers.ws 10:24:43 098m03r9f80239802389f0m9KDKLKLJDKLJm0983m890DMOm03 dlkfj3hljf4h3klhl00000002998 098 03 9 80239802389 0 9 0983 890 03 3 4 3 00000002998 ========================= and the code now is ========= | txt nums | Transcript cr; show: '*** hiddennumbers.ws '; show: Time now printString ; cr. txt := '098m03r9f80239802389f0m9KDKLKLJDKLJm0983m890DMOm03 dlkfj3hljf4h3klhl00000002998'. Transcript cr; show: txt ; cr. txt := txt replacingAllRegex: '\D+' with: ' '. " gst code " " replace all alphas with space " Transcript cr; show: txt ; cr. ==================================================
|
Free forum by Nabble | Edit this page |