in reply to Re: Test if string is already quote()'d?
in thread Test if string is already quote()'d?
As adrianh has already noted, you can't say for sure if 'hello' is a quoted string or an unquoted one waiting for its quotes to be escaped.
A better regexp would be
print "quoted" if $string =~ /^["'].*\1$/;
But then again, it won't solve the problem of checking for escaped quotes within the string.
Take 'O'Reilly', for example. It will pass the quoted test, but it will have a unescaped quote inside.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: Test if string is already quote()'d?
by demerphq (Chancellor) on Jun 15, 2003 at 14:54 UTC | |
by Seumas (Curate) on Jun 17, 2003 at 23:15 UTC | |
Re: Re: Re: Test if string is already quote()'d?
by sgifford (Prior) on Jun 15, 2003 at 17:43 UTC | |
Re: Re: Re: Test if string is already quote()'d?
by meonkeys (Chaplain) on Jun 15, 2003 at 18:14 UTC |