mIRC Home    About    Download    Register    News    Help

Topic Options
#60886 - 18/11/03 08:50 AM parse line
Kester Offline
Bowl of petunias

Registered: 18/11/03
Posts: 2
I would like to parse a line of text, using regular expressions (i have good knowlegde of reg expr, don't worry), but I can't seem to find a way to parse a string that contains comma's.
Code:
 $regexp(%var,re) 

works fine, as long as the %var doesn't contian any comma's. I tried to put all sorts of brackets around %var, but I couldn't find a solution...
Can anyone help me?

Top
#60887 - 18/11/03 08:59 AM Re: parse line
qwerty Offline
Hoopy frood

Registered: 07/01/03
Posts: 2523
I'm not sure what you mean. Commas in variables work fine:
Code:
//var %a = this,is,a,test | echo -a $regex(%a,/is/)
Maybe the problem is that you used commas directly in the <re> parameter. For example, this:
Code:
//var %a = this,is,a,test | echo -a $regex(%a,/this,is/)
will NOT work. As commas are the parameter separators in identifiers, they shouldn't be used directly inside parameters: they have to be escaped. In regex, you can use \x2C, but generally you can use $chr(44). For example:
Code:
//echo -a $upper($+(this,$chr(44),is))
_________________________
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Top
#60888 - 18/11/03 09:06 AM Re: parse line
Kester Offline
Bowl of petunias

Registered: 18/11/03
Posts: 2
tnx, that was the problem indeed, i didn't know that the comma should be escaped in the regular expression itself

Top
#60889 - 01/12/03 11:07 AM Re: parse line
cold Offline
Hoopy frood

Registered: 25/02/03
Posts: 810
Loc: Brazil
Also remember that the expression itself could be in a %variable as well, so you could use $regex(%a,%b) too.
_________________________
* cold edits his posts 24/7

Top