[Newbies] VB-Regex issue...

Prashanth Hebbar hebbarp at gmail.com
Mon Aug 1 10:14:58 UTC 2011

On Mon, Aug 1, 2011 at 1:32 PM, Lawson English <lenglish5 at cox.net> wrote:

> anyone familiar with VB-Regex package?
> this code should be returning an ordered collection of 25 hits (I thought).
> Instead it returns one long string of all 25 hits:
> http://pastebin.com/eGcX6vg2
> source string: http://pastebin.com/AkyQrXGD
> I've been playing with this one for an several hours.  I can't tell if the
> strings are too complicated or if I'm just using the wrong syntax, though
> the simple example works just fine.
> '\w+' asRegex matchesIn: 'Now is the Time' => an OrderedCollection('Now'
> 'is' 'the' 'Time')
Perhaps it was the string size which has multiple quotes and is not all
escaped. Sean DeNigris writes about an interesting trick to preserve all the
quotation marks inside long strings, especially html-strings. See this post
from Sean for this trick http://seandenigris.com/blog/?p=647.

This code returns the OrderedCollection as expected by you.

source := htmltext678 contents.
aString := '<a href="billionaires08_(.*)html">(.*).</a></td>'.
matcher := RxMatcher forString: aString.
matcher matchesIn: source.
"Transcript show: (matcher matchesIn: source); cr."

The htmltext678 is the TextMorph where I stored your html page and extracted
the contents to preserve all inline quotes. I took a shorter match-string

One thing i noticed in the referred code that there was an ordered
collection being created which wasn't doing anything.

Prashanth Hebbar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20110801/83898da5/attachment.htm

More information about the Beginners mailing list