Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
moonwlf
Novice


Joined: 14 May 2001
Posts: 33
Location: USA

PostPosted: 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,
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: 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
Reply with quote
moonwlf
Novice


Joined: 14 May 2001
Posts: 33
Location: USA

PostPosted: 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.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: 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)

Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net