mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Apr 2004
Posts: 759
M
Hoopy frood
OP Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
$*:TEXT:m/regular expression/switches:#:/echo message: $1-

m in Java toggles ^$ matching a string or lines on multiline input however since almost nothing in mIRC is multiline whats the use for m ?


$maybe
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
/m (at the end) is multiline, even in mIRC. m (at the start) simply means the next character is to be used as regex delimiters. This means you can use $regex(abc,m~^abc$~) or m^^abc$^ instead of /^abc$/

Joined: Apr 2004
Posts: 759
M
Hoopy frood
OP Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
In java its at the beginning :tongue:

I never knew that thanks hixxy smile


$maybe
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Np smile

Just to add; as long as you enclose the regex in delimiters properly you can use almost anything:

Code:
//echo -a $regex(m,mmmm)


Echos "1"

And a lot of people don't realise, but you don't need to escape the delimiter to use it in an expression:

Code:
//echo -a $regex(/,/^/$/)

Joined: Sep 2003
Posts: 261
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
I thought m/ meant match frown.

Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
(General Reply)

I believe the 'm' prefix specifies 'match', as opposed to 's' which is 'substitute' and 'tr' (or 'y') which is 'transliterate'. This does also let you choose your own delimiter character.

A useful feature is shown below in a description from Robert's Perl Tutorial:

Quote:

How to Avoid Making Mountains while Escaping Special Characters
You want to match this; http://language.perl.com/faq/ . That's a real (useful) URL by the way. Hint. To match it, you need to do this:

/http:\/\/language\.perl\.com\/faq\//;

which should make the awful metaphor above clearer, if not
funnier. The slash, / , is not
normally a metacharacter but as it is being used for the regular expression
delimiters, it needs to be escaped. We already know that . is special.
Fortunately for our eyes, Perl allows you to pick your delimiter if you prefix it with 'm' as this example shows. We'll use a #:

m#http://language\.perl\.com/faq/#;

Which is a huge improvement, as we change / to # .
We can go further with readability by quoting everything:
m#\Qhttp://language.perl.com/faq/\E#;

The \Q escapes everything
up until \E or the regex delimiter (so
we don't really need the \E above). In this case #
will not be escaped, as it delimits the regex.


-genius_at_work


Link Copied to Clipboard