Try (.|\n) instead.

Andy

----- Original Message -----
From: "Bennett Haselton" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, April 07, 2001 11:08 PM
Subject: how to represent "any character" (incl. \n) in regexp?


> 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?
>
> -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