mIRC Home    About    Download    Register    News    Help

Print Thread
#185903 15/09/07 08:41 PM
P
pouncer
pouncer
P
-

Joined: Sep 2005
Posts: 2,630
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,630
Code:
/^([A-Z][a-z]{2}) (?1) \d{4} (\d{4}:)(?2)\d{4} PMD-\d{4} 9999$/

P
pouncer
pouncer
P
thanks alot hixxy, it is perfect!!!

can i ask what the (?1) and (?2) do?

Joined: Sep 2005
Posts: 2,630
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,630
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}

Joined: Jul 2006
Posts: 107
L
Vogon poet
Offline
Vogon poet
L
Joined: Jul 2006
Posts: 107
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.)

Joined: Dec 2002
Posts: 3,015
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,015
He edited his post after making it, it was originally regarding matching registration keys for some program or other.

Joined: Jul 2006
Posts: 107
L
Vogon poet
Offline
Vogon poet
L
Joined: Jul 2006
Posts: 107
Ah ok. Thanks. Thought I was losing my mind smile

I'd looked for an 'edited' notation on that post. Apparently that is optional.


Link Copied to Clipboard