[prev in list] [next in list] [prev in thread] [next in thread] 

List:       squeak-beginners
Subject:    Re[Newbies] gular Expression Question
From:       pbohuch <pbohuch () shaw ! ca>
Date:       2008-01-25 13:53:32
Message-ID: 15068867.post () talk ! nabble ! com
[Download RAW message or body]


Hi everyone,

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|

self halt.
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
something?


-- 
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.

_______________________________________________
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic