$select =~ s/\|\|\'\,\'\|\|$//;
Not being regexp virtuoso, would like to ask if it possible to escape
group of characters instead of escaping each one, i.e. something like:
$select =~ s/\||','||$//;
Thanks,
Andrew
You don't need to escape single quotes or commas since they are not
special regexp characters.
> Not being regexp virtuoso, would like to ask if it possible to escape
> group of characters instead of escaping each one, i.e. something like:
>
> $select =~ s/\||','||$//;
A quick glance into perlre gives you the answer:
$select =~ s/\Q||','||\E$//;
--Ala
Actually, *you* just gave the answer, Ala, without any need for the OP
to look in perldoc perlre. ;-) (To OP: It's a good idea to do so anyway.)
Two further comments:
- \E right before $ is apparently redundant.
- See also perldoc -f quotemeta.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
> Using regexp to strip off ||','|| from the end of select query.
Highly insufficient parameters. You have failed to state
if this case is always true, sometimes true, nor if this case
contains all of those characters, some of those characters,
none of those characters, nor have you stated if your case
ends with a newline. You have also failed to state what
precedes your case example.
Do consider providing clear, concise and coherent parameters
with which a reader may work, sans guessing.
Purl Gurl
--
#!perl
$input = "no parameters set unknown ||','||";
substr ($input, rindex ($input, "||','||"), 7, "");
print $input;
PRINTED RESULTS:
________________
no parameters set unknown
apparently not
gnari
>Highly insufficient parameters.
Andrew, a word of warning if you are new here. Purl Gurl doesn't have
a fine reputation for accuracy in this newsgroup. Do a bit of
Googling in the archives if you want more information, but for the
time being I recommend you don't adopt his/her/its advice without
checking it first.
Henry Law <>< Manchester, England
Okay.. Guess "apparently" was a bad choice of word. ;-) New try:
- \E right before $ is redundant.
(context deliberately removed by Law)
> >Highly insufficient parameters.
> Purl Gurl doesn't have a fine reputation for accuracy in this newsgroup.
For the originating author, I suggest, "...providing clear, concise
and coherent parameters with which a reader may work, sans guessing."
You state, "Purl Gurl doesn't have a fine reputation for accuracy
in this newsgroup."
My, you are quite the Queen's git.
Purl Gurl
you misunderstand. I was not commenting on your wording,
but on your meaning. I am saying you are wrong.
the \E is not redundant.
gnari
??
Aha, now I understand. Since $ is a pattern metacharacter, \E *is*
needed, or else the pattern would not match without the literal
character $ being included in the string.
My bad. I should know better than questioning an answer to a regex
question without tests.
Thanks, gnari! Sorry for any confusion my comment may have caused.
> My, you are quite the Queen's git.
is that a decimal git, or do we have moronity in town, tediously, and
yet again?