mIRC Home    About    Download    Register    News    Help

Print Thread
$regex() #13196 26/02/03 09:17 AM
Joined: Dec 2002
Posts: 94
K
krunch Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Dec 2002
Posts: 94
using
Code:
 if ($regex($1-,/\b(string|string1)\b/gi)) { echo -a STRING WAS: $regml($1-,$regml($1-)) }


that does not work how do i get regex() to tell me the string that triggered it?



Lets get dirty
Re: $regex() #13197 26/02/03 10:29 AM
Joined: Dec 2002
Posts: 699
N
Nimue Offline
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
$regml(1) is the first match, $regml(2) is the second, etc.
$regml(0) is the total matches.

Re: $regex() #13198 26/02/03 10:29 AM
Joined: Dec 2002
Posts: 17
S
Sojourn Offline
Pikka bird
Offline
Pikka bird
S
Joined: Dec 2002
Posts: 17
you need to assign a name to the regular expression so that $RegEx() knows to store the matches, and $RegML() knows where to fetch them from. Your $RegML() parameters are also incorrect. The following should work:

if ($regex(Junk, $1-,/\b(string|string1)\b/gi)) { echo -a STRING WAS: $regml(Junk, 1) }

Note: Since you're using the /g flag, you may get more than one match, so you may want to loop the $RegML() results.

Re: $regex() #13199 26/02/03 10:45 AM
Joined: Dec 2002
Posts: 77
B
BlackAle Offline
Babel fish
Offline
Babel fish
B
Joined: Dec 2002
Posts: 77
Assigning a name to a $regex is optional.

Re: $regex() #13200 27/02/03 04:16 AM
Joined: Dec 2002
Posts: 94
K
krunch Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Dec 2002
Posts: 94
cool
so that displays the string, how about the whole part of it
so
if ($regex($1-,/\b(string|string1)\b/gi)) { echo -a STRING WAS: $regex(1) }
that will only take that string outa it
say some1 typed string1blahblahblah
how would i get the blah's that are connected to string1?


Lets get dirty
Re: $regex() #13201 27/02/03 07:56 AM
Joined: Dec 2002
Posts: 271
N
NightChillz Offline
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 271
//echo -a $regsub(string1blahblahblahblah,/(blah)/gi,,%a) $remove(string1blahblahblahblah,%a)

that will give you an echo of: 4 blahblahblahblah

for the the amount of matches to "blah" in string, and the regsub substitutes matches in string with ,whatever, and sets result to %a in this case, ,whatever, in this case is ,, = nothing, deletes it, so the all we have left after all blah matches are subed out, is string1, so then we can remove that from the whole string that we started with, and voila, your blahs are all there :P