Re[Newbies] gular Expression Question
pbohuch at shaw.ca
Fri Jan 25 13:53:32 UTC 2008
I am new to smalltalk and have been having trouble using regular
expressions. I have installed Vassili Bykov’s RegEx package using the
Monticello Browser. Here is what my issue is. I have a test string that I
want to "push" into an OrderedCollection.
testString := 'this is a test'.
testCollection := '(^\s*)|(\s)|\w+' asRegex matchesIn: testString.
Now I can inspect this in a workspace and it shows me an ordered collection
of all the elements of the string. However when I attempt to use this in a
method, and call the method from a TestCase, I get an infinite loop.
Stepping through the method I found that the "asRegex" portion of the
statement above works correctly. Where is seems to be crashing is in the
"matchesIn:" method. Can anyone please let me know what I am missing? The
exact statements in my test case are:
| myTokens myString|
myTokens := OrderedCollection new.
myString := 'this is a test'.
myTokens := '(^\s*)|(\s)|\w+' asRegex matchesIn: myString.
self shouldnt: [myTokens isEmpty].
If you step through this method in the Test Runner you will see it never
makes it through the matchesIn: method. Am I forgetting to instantiate
View this message in context: http://www.nabble.com/Regular-Expression-Question-tp15068867p15068867.html
Sent from the Squeak - Beginners mailing list archive at Nabble.com.
More information about the Beginners