![](templates/Classic/images/spacer.gif) |
moonwlf Novice
Joined: 14 May 2001 Posts: 33 Location: USA
|
Posted: Thu May 08, 2003 2:33 am
regular expressions |
Hello,
Has anyone had experience in capturing lines of text with regular expressions? The help file says to use a reparse trigger to capture the text from the pattern using a new trigger pattern. I haven't had any luck with this. The regular expression I use filters out the text that I want to keep. The expression I use is to capture any url.
([^:s]+)://([^:/s]+)(:([0-9]+))?(/[^s]+)?
I want to be able to save the url to a file.
anyone have any suggestions?
Thanks, |
|
|
![](templates/Classic/images/spacer.gif) |
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Thu May 08, 2003 4:27 pm |
Suggestions:
Use standard zScript.
#TR {(%w://[a-zA-Z0-9~.~-~?~%~~])}
Avoid using "excluded range" patterns.
[^:s]
LightBulb
Advanced Member |
|
|
![](templates/Classic/images/spacer.gif) |
moonwlf Novice
Joined: 14 May 2001 Posts: 33 Location: USA
|
Posted: Thu May 08, 2003 11:17 pm |
quote:
Suggestions:
Use standard zScript.
#TR {(%w://[a-zA-Z0-9~.~-~?~%~~])}
Avoid using "excluded range" patterns.
[^:s]
LightBulb
Advanced Member
The reason I went with regular expressions is because of its flexability and power of matching patterns that normal zscript can't match without extensive string comparisons. What this pattern does is check for a url pattern with or without a port, with or without a page after the domain name and can pull the url out of a line of text. This could be done with a normal pattern by you would probably have to use several trigger states and string comparisons. So if I could just grab the matched text from the line with the regular expression it would be a lot similar. Now I played with #CW and it colors the matched text correctly but apparently the sequence it uses to color the matched text is an internal mechanism. There seems that there should be a predefined variable to do this but I haven't had any luck with this. |
|
|
![](templates/Classic/images/spacer.gif) |
Zugg MASTER
![](images/avatars/164475849040f41c23b22fe.gif)
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Sat May 10, 2003 12:10 am |
You cannot use () in regular expressions to save any values from the matched text. The () feature is only part of the zMUD patterns. Regular Expressions don't have that kind of functionality.
So what the help file is talking about is using a regular expression as your primary trigger to match the line, then use ReParse with a normal zMUD expression with () to pull out the text you want.
I've I misunderstood, then I apologize. zMUD uses a 3rd party component to handle regular expressions, and I haven't done any extensive checking of it to see if it has bugs (since there's nothing I can do about it if it does)
![](http://www.zuggsoft.com/common/zugg.gif) |
|
|
![](templates/Classic/images/spacer.gif) |
|
|