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
Atreides096
Beginner


Joined: 26 Apr 2004
Posts: 15
Location: USA

PostPosted: Mon Feb 19, 2007 8:43 pm   

Weird stringlist problem
 
Trying to match a stringlist in a regular expression... I'm apparently doing something wrong, but can't figure out what I am doing wrong...

Code:
#va tempvar {a|b|c|d}
#trigger {({@tempvar})$} {#say match}

That works just fine. But then I've tried everything I can think of.. using zmud's conversion button, as well as:
Code:
#regex {(?:@tempvar)}
#regex {(@tempvar)}
#regex {((?:@tempvar))}
#regex {(?:(@tempvar))}

and so on, and none of them will match. My guess is that I am breaking a procedural rule rather than incorrect syntax... anyone know what I am doing wrong?

Thanks a lot :)
Reply with quote
intoK
Apprentice


Joined: 18 Feb 2007
Posts: 190

PostPosted: Mon Feb 19, 2007 10:17 pm   
 
try #REGEX {@{tempvar}} :P
Reply with quote
Atreides096
Beginner


Joined: 26 Apr 2004
Posts: 15
Location: USA

PostPosted: Mon Feb 19, 2007 11:05 pm   
 
Didn't work, just did things like change my prompt to:

<HP: 13 (?)/130>0 {#addkey _SubsConfig Sanc Yes}
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Mon Feb 19, 2007 11:43 pm   
 
Code:
#REGEX {\b(@tempvar)\b} {#say Matched %1}
#REGEX {\b(?:@tempvar)\b} {#say Matched}


The first captures the value of the word and the second just matches without capturing. You shouldn't need the \b around it if you don't want to capture only whole words (i.e., you want sub-string matches).
Reply with quote
intoK
Apprentice


Joined: 18 Feb 2007
Posts: 190

PostPosted: Mon Feb 19, 2007 11:56 pm   
 
#VA v_b0 {a|b|c|d}
#TR {^(@{v_b0}) (.*)$} {#WIN debug b0 %2} "" {regex}
works for me, theres 'feature' in regex implementation, it wont take var names starting with _...

rephrase: so any sort of (?_varname:expression) will fail
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