Re: regexp





"John W. Krahn" <krahnj@xxxxxxxxx> wrote: oryann9 wrote:
In this regexp

my $regexp = qr/(\d+\x3a1108
|\w+\x3a1108{1,} ) /;

vs.

my $regexp1 = qr/(\d+\x3a1108
|\w+\x3a1108){1,} /;

does the {1,} construct outside the parens () mean the entire string 1
or more times and within the parens mean only the last string \x3s1180
1 or more times?

What is the diff?

Modifiers affect the preceding character or grouping so in the first example
the modifier is attached to the character '8' and in the second example the
modifier is attached to the parentheses which will affect the entire contents
of the enclosing parentheses.

Also note that \d is a subset of \w so anything that matches \w will also
match \d.


John
--

ok did not know the subset info.
thx agn!





---------------------------------
Looking for earth-friendly autos?
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.

Relevant Pages

  • Re: regexp
    ... does the construct outside the parens mean the entire string 1 ... modifier is attached to the parentheses which will affect the entire contents ...
    (perl.beginners)
  • Re: regexp
    ... does the construct outside the parens mean the entire string 1 or ... Autos. ...
    (perl.beginners)
  • Re: regexp
    ... does the construct outside the parens mean the entire string 1 or more times ... No, not the whole string, just the last character, which is 8 (not 0 ...
    (perl.beginners)
  • Re: Regexp, ***= and subexpressions
    ... specified that the user's input be treated as a literal string rather than ... -exact] in cases where regexp isn't required:P ... Seems to be that regexp can't match word boundaries at "non-word" ... But now Earth has rotated and I can get back to sleep. ...
    (comp.lang.tcl)
  • Re: Regexp: Case-insensitive matching | N factorial
    ... a regexp component that matches a string of letters, ... Will match the string 'cat' anywhere it appears regardless of case. ... Javascript regular expressions have an alternative operator '|' (kind ...
    (comp.lang.javascript)