On Jul 17, 2006, at 11:33 AM, Maxim wrote:
But I am totally frustrated in regexp part in the script:
/^DR\d+.*?(\d+).*?(\d+)(.+)/
Could you please explain it? Or maybe you have a link to intelligible
guide for perl regexp?
perldoc perlre is a pretty detailed description of perl's regexp. If
you want to really get into it you can install YAPE::Regex::Explain
and see how it parses everything out.
http://search.cpan.org/~pinyan/YAPE-Regex-Explain-3.011/
The specific answer is:
/^DR\d+.*? #^ means start of the line, DR is a literal 'D' followed
by an 'R',
# \d is the digit character set, + means one or
more of the preceding,
# so one or more digits.
# The '.' is any character, '*' is zero or more
times and '?' is "non-greedy",
#which means the match should stop as soon as
possible,
#ie, before blasting past the next match
(\d+).*? #parens mean 'capture' so this is capture one or more
digits.
#Then there's that non-greedy, match anything
construct again
(\d+)(.+) #This is the same as above except instead of the non-
greedy thing
#it captures the description string with the 'one
or more of anything'
#construct.
/x #I added the 'x' on here because it lets you put comments into a
regex like I did above.
Hope this helps,
Peter Cornelius
Sr. Software Engineer
LiveOps (http://liveops.com)
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>