On 10/26/07, yitzle <[EMAIL PROTECTED]> wrote: > @re = $x=~/(\w+;\w+);{0,1}/g; > Array @re holds the resulting matches (inside the brackets) of the > RegEx $x=~/(\w+;\w+);{0,1}/g > > $x=~/(\w+;\w+);{0,1}/g > the /g means don't stop after one match. > > /(\w+;\w+);{0,1}/ > \w is a "word" > This matches one or more word(s) followed by a semicolon, again one or > more words, the 0 or 1 semicolons - the greater of the two, I suppose; > this allows you to not end in a semicolon. > I suspect the {0,1} would have the same affect as ?
\w matches a word character as Perl defines them (alphanumeric and the underbar character), \w+ matches one or more of them. Perl's definition may not match yours (e.g. "can't" isn't a word because the single quote/apostrophe character is neither alphanumeric nor an underbar). from perldoc perlre A "\w" matches a single alphanumeric character (an alphabetic character, or a decimal digit) or "_", not a whole word. Use "\w+" to match a string of Perl- identifier characters (which isn't the same as matching an English word). If "use locale" is in effect, the list of alphabetic characters generated by "\w" is taken from the current locale. See perllocale. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/