mIRC Homepage


Posted By: krunch

$regex() - 26/02/03 09:17 AM

 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?

Posted By: Nimue

Re: $regex() - 26/02/03 10:29 AM

$regml(1) is the first match, $regml(2) is the second, etc.
$regml(0) is the total matches.
Posted By: Sojourn

Re: $regex() - 26/02/03 10:29 AM

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.
Posted By: BlackAle

Re: $regex() - 26/02/03 10:45 AM

Assigning a name to a $regex is optional.
Posted By: krunch

Re: $regex() - 27/02/03 04:16 AM

so that displays the string, how about the whole part of it
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?
Posted By: NightChillz

Re: $regex() - 27/02/03 07:56 AM

//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
© 2020 mIRC Discussion Forums