mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2011
Posts: 3
T
twenex Offline OP
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Nov 2011
Posts: 3
1. this work:
Code:
if ($regex($1-,/.+? musiclist\S+ \[.+?\] \(.+?\) \(\*(\d+).+?\)$/iS))

2. this give error:
Code:
if ($regex($1-,/.+? musiclist\S+ \[[^\]]+\] \([^\)]+\) \(\*(\d+)[^\)]+\)$/iS))


can someone help me with the regexp #2, throw an error /if: invalid format (line, script), do i need to escape chr or space something?

The test text:
Code:
bla bla random whatever musiclist...!!! [artist] (song whatever) (*77 list)

store captured digit 77 to $regml(1)

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
You can probably simplify it to:

Code:
$regex(%t,/(\d*) list\x29$/iS)


Though I didn't have time to really look at it before having to head out, so I might have missed something.


Invision Support
#Invision on irc.irchighway.net
Joined: Jul 2006
Posts: 4,151
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,151
That is because you're indeed having an invalid format, you need to have the same number of '(' and ')' for a given parameter of an identifier, you are using \) which is why there one more ')'.
Possible workaround:
- put the pattern in a local variable and pass the variable as the parameter (clearer in general)
- use the octal or hexa representation of the ')' character
- use $chr() and $+ directly

Last edited by Wims; 20/12/11 12:04 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Nov 2011
Posts: 3
T
twenex Offline OP
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Nov 2011
Posts: 3
thanks for the info.

Joined: Nov 2011
Posts: 3
T
twenex Offline OP
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Nov 2011
Posts: 3
Originally Posted By: Riamus2
You can probably simplify it to:

Code:
$regex(%t,/(\d*) list\x29$/iS)


Though I didn't have time to really look at it before having to head out, so I might have missed something.


thanks, but actually that isn't finish yet i still need to capture:
musiclist...!!! [artist] (song whatever) (*77 list)
something like this:
Code:
(?:musiclist)\S+ \[([^\x5D]+)\] \(([^\x29]+\)) \(\*(\d+)[^\x29]+\)$


i need the "artist" "song whatever" "77" and the musiclist is important.

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Why do you make the regex pattern complicated? Would you please give an exact sentence that you want to match, not just drop a line in a piecemeal fashion.

Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
Code:
var %t = musiclist...!!! [artist] (song whatever) (*77 list)
var %m = /musiclist\S+ \[([^\]]+)\] \(([^\)]+)\) \(\*(\d+)[^\)]+\)$/i
echo -a $regex(%t,%m) -> $regml(1) -> $regml(2) -> $regml(3)



$regml(1) = "artist"
$regml(2) = "song whatever"
$regml(3) = "77"


I am SReject
My Stuff
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Originally Posted By: twenex
i need the "artist" "song whatever" "77" and the musiclist is important.


Ah, sorry. I only had a few minutes to look and the end of your post said you needed the 77. I didn't even look over what you already had to see what it was attempting to do.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard