mIRC Homepage
Posted By: pouncer validation check - 15/09/07 08:41 PM
-
Posted By: hixxy Re: validation check using regex - 15/09/07 08:55 PM
Code:
/^([A-Z][a-z]{2}) (?1) \d{4} (\d{4}:)(?2)\d{4} PMD-\d{4} 9999$/
Posted By: pouncer Re: validation check using regex - 15/09/07 09:08 PM
thanks alot hixxy, it is perfect!!!

can i ask what the (?1) and (?2) do?
Posted By: hixxy Re: validation check using regex - 15/09/07 09:16 PM
When you put a pattern inside brackets, the regex engine will remember the match in case you want to use it again later, so if you used the regex:

Code:
/^([A-Z])([a-z]{4})$/


On the string:

Code:
Zebra


Then \1 would refer to the letter "Z", because it is the first match you made, and \2 would be "ebra", because it's the second. (?N) differs from \N because it remembers the pattern, not the result. So ([A-Z][a-z]{4})(?1) would be a shorthand way of writing ([A-Z][a-z]{4})(?:[A-Z][a-z]{4})

Or in the case of the first example, (?1) would be [A-Z] and (?2) would be [a-z]{4}
Posted By: LonDart Re: validation check using regex - 16/09/07 06:32 AM
I really appreciate your regex skills and your explanation.

But this is driving me crazy....
How the heck did you know what he wanted?!

The entire text of the original post consists of a hyphen.

(I am soooo lost.)
Posted By: Collective Re: validation check using regex - 16/09/07 06:36 AM
He edited his post after making it, it was originally regarding matching registration keys for some program or other.
Posted By: LonDart Re: validation check using regex - 16/09/07 07:01 AM
Ah ok. Thanks. Thought I was losing my mind smile

I'd looked for an 'edited' notation on that post. Apparently that is optional.
© mIRC Discussion Forums