mIRC Homepage

Regex match exactly n times or exactly n1 times ?

Posted By: Adrenalin

Regex match exactly n times or exactly n1 times ? - 31/01/04 05:02 PM

I trying some think like that /^[a-z]{6}|[a-z]{10}$/ but it work like /^[a-z]{6,}$/ ;] I need to match only 6 or 10..

Can anyone explain me why it work like that.. And make it works correctly ?
Posted By: Collective

Re: Regex match exactly n times or exactly n1 times ? - 31/01/04 05:20 PM

/^([a-z]{6}|[a-z]{10})$/ or /^[a-z]{6}$|^[a-z]{10}$/
Posted By: Adrenalin

Re: Regex match exactly n times or exactly n1 time - 31/01/04 05:34 PM

Yap.. That was easy.. Now i understand the mistake wink Thank you.
Posted By: Raccoon

Re: Regex match exactly n times or exactly n1 time - 31/01/04 06:04 PM

And unless you're using $regml or $regsub to backreference, you should use:
/^([color:blue]?:[a-z]{6}|[a-z]{10})$/[/color]

Just a bit faster, telling the regex engine to group but not backref.
© 2022 mIRC Discussion Forums