On Sat, 7 Apr 2001, Bennett Haselton wrote:

> Since according to p. 25 of "Programming Perl" by Wall, "." stands for "any
> character except newline" and "\n" stands for "newline", and [<set>]
> matches "any character in <set>", I thought you could use "[.\n]" to match
> "any character":
> 
> >>>
> $string = 'abc';
> if ($string =~ /([.\n])/)
> {
>       print "yes: $1\n";
> }
> else
> {
>       print "no\n";
> }
> >>>
> 
> But this prints out "no".  It turns out that inside the square brackets,
> "." represents the period character and not "any character"; if you change
> string to "a.bc", the script print "yes: ." .  In that case, how do you
> represent "any character" inside a regexp?
>

The character class [.\n] only matches one character. Within a 
character class most of the regex meta-characters lose their special
meanings so your character class will match a single character if it
is a new-line or a period. To match any character you could use the
pattern (?:.|\n). 

**** [EMAIL PROTECTED] <Carl Jolley>
**** All opinions are my own and not necessarily those of my employer ****

 
>       -Bennett
> 
> [EMAIL PROTECTED]     http://www.peacefire.org
> (425) 649 9024
> _______________________________________________
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
> 

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to