KEVIN ZEMBOWER <[EMAIL PROTECTED]> wrote:
:
: I'm trying to discard any URL with any character that is not
: an upper- or lower-case letter, digit, or the characters
: $-_.+!*'(), . I realize that some other characters can be
: used in special circumstances, but I don't have to allow for
: any of these in my program.
:
: I thought that my perl statement:
: if ($url =~ /^[^A-Za-z0-9$-_.+!*'(),]+$/) {
: print "Invalid character in URL at line $.: $url\n";
: next;
: }
: is saying:
: if the variable $url contains any characters not in the set
: [A-Za-z0-9$-_.+!*'(),]+$/), print "Invalid ..."
No. It is saying if ALL characters are invalid ...
Ignore the character class and look at the rest. There
is no room for a valid character:
/
^ # start at the beginning of the string
[^A-Za-z0-9$-_.+!*'(),]+
$ # end at the end of the string
/
Your anchors are dragging you down. You want to find the
first invalid character. After that it doesn't matter. This
should be fine.
/[^A-Za-z0-9$-_.+!*'(),]/
HTH,
Charles K. Clarkson
--
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
254 968-8328
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>