Quick perl question

pushVTEC

Senior member
Aug 30, 2003
265
0
0
Can someone explain this line to me, I know /d+ searches for a string of digits, but the other stuff could use some explaining.

if($line =~ /:x:(\d+):\d+:([^:]*):([^:]+):([^:]+)/) {

I know it says if line contains then i'm lost.

Does anyone have a good site where the various stuff in that is explained?
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
(i use a b and c instead of 10/11/12 to keep the alignment more readable)

parts of regex:
1. :
2. x
3. :
4. (\d+)
5. :
6. \d+
7. :
8. ([^:]*)
9. :
a. ([^:]+)
b. :
c. ([^:]+)

explanation:
1. a colon
2. then an x
3. then a colon
4. then one or more digits
5. then a colon
6. then one or more digits
7. then a colon
8. then possibly some non-colon characters
9. then a colon
a. then definitely some non-colon characters
b. then a colon
c. then definitely some non-colon characters

parentheses are only for grouping; all of the parentheses in this case could be taken out and it'd work just the same. (\d+) matches the same as \d+.
 

pushVTEC

Senior member
Aug 30, 2003
265
0
0
So the / and / signify the beginning and end of using regular expressions right? BTW thanks a lot for the translation :)