[REBOL] Re: A question about a regular expression
From: lethalman::fyrebird::net at: 17-Oct-2004 14:01
Gabriele Santilli wrote:
>Hi Lethalman,
>
>On Sunday, October 17, 2004, 1:10:12 PM, you wrote:
>
>>>You only need "*" or something else too?
>>>
>>>
>>>
>L> ? is good too... :)
>
>Ok.
>
>L> PS: se vuoi parla anche italiano
>
>In inglese ci capiscono anche gli altri. ;-)
>
>One way is to use FIND/ANY that supports wildcards. However, like
>most RE engines do, it can match too much:
>
>>>find/any/tail "<a href='http://bla'>Test</a><a href='http://blabla'>Test2</a>" "<a
href='*'>"
>>>
>>>
>== "Test2</a>"
>
>Another way is to convert the strings to PARSE rules, and then use
>them.
>
>>>wildcards: "*?"
>>>text: complement charset wildcards
>>>result: []
>>>wild-rule: [some [copy str any text (append result str) ["*" (append result 'thru)
| "?" (append result 'skip)]]]
>>>parse/all "<a href='*'>" wild-rule
>>>result
>>>
>>>
>== ["<a href='" thru "'>"]
>
>Note that this won't work if your string has something like "*?"
>or "**" in it (it will work for "?*"). You can enhance it to
>support that if you think you need it.
>
>Now you can:
>
>>>parse/all "<a href='http://bla'>Test</a><a href='http://blabla'>Test2</a>" [result
mark:]
>>>
>>>
>== false
>
>>>mark
>>>
>>>
>== "Test</a><a href='http://blabla'>Test2</a>"
>
>I think this should be enough to give you a start. :)
>
>Regards,
> Gabriele.
>
Yes i've already found the FIND/ANY solution, i thought there was
another way more simple and clean.
Thanks to everyone!
--
Fyrebird Hosting Provider - Technical Department