Brano Gerzo schreef:
> Dr.Ruud [DR], on Thursday, July 13, 2006 at 21:05 (+0200) wrote these
> comments:
>
>
> as you helped me much, here is example of RE:
>
> my $re =
>
'^\s*(?:(\d+)\s+)?(\w+(?:\s+\w+)*?)(?:\s+((?:sq|hy|ay|bs|bg|hr|cs|da|nl|
en|et|fi|fr|de|gr|he|hu|zh|it|ja|kk|lv|pl|pt|pb|ro|ru|sr|sk|sl|es|sv|th|
tr|uk|al)(?:\s*,\s*|sq|hy|ay|bs|bg|hr|cs|da|nl|en|et|fi|fr|de|gr|he|hu|z
h|it|ja|kk|lv|pl|pt|pb|ro|ru|sr|sk|sl|es|sv|th|tr|uk|al)*)?)(?:\s+(\d+)c
d)?\s*$';


(1) You have many \s in there, that are actually meant as spaces or
maybe tabs too. The \s also contains LF, CR, FF:

perl -wle '$_=chr and /\s/ and print ord for 0..255'
9
10
12
13
32

and even more:

perl -Mutf8 -wle '$_=chr and /\s/ and printf "%x\n", ord for 0..0xD7FF'
9
a
c
d
20
1680
180e
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
200a
2028
2029
202f
205f
3000

[[:blank:]] is what you mean, see perldoc perlre.



(2) There vbar in front of the second sq is an error.


It is much better to write it in layers, and to use embedded whitespace:

my $lang = q/(?x:
sq|hy|ay|bs|bg|hr|cs|da|nl|en|et|fi|fr|de|gr|he|hu|zh|
it|ja|kk|lv|pl|pt|pb|ro|ru|sr|sk|sl|es|sv|th|tr|uk|al)/ ;

# (the x allows whitespace inside the regex).

my $sp = q/[[:blank:]]/ ;

my $re = qq/
^ $sp* (?:(\d+)$sp+)?
  (\w+(?:$sp+\w+)*?)
  (?:$sp+((?:$lang)(?:$sp*,$sp*$lang)*)?)
  (?:$sp+(\d+)cd)?$sp*
\$/ ;

Then use it as "m/$re/x".



> Thanks.

You're welcome.

-- 
Affijn, Ruud

"Gewoon is een tijger."



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to