[Newbies] VB-Regex issue...
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:
> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners