I can't figure this regex out, Help please.

C

Charlie White

I have a string that has been excaped with "\"

eg. "This is charlie\'s company\'s May\\June"

what I would like to end up with is

"This is charlie's company's May\June"

Everything I tried drops out the \ between MayJune also

Anyhelp in this regex would be gratefully appreciated

CW
 
J

Jürgen Exner

Charlie said:
I have a string that has been excaped with "\"

eg. "This is charlie\'s company\'s May\\June"

what I would like to end up with is

"This is charlie's company's May\June"

Sorry for being dense, but those two strings are identical already.

jue
 
P

Paul Lalli

Charlie said:
I have a string that has been excaped with "\"

eg. "This is charlie\'s company\'s May\\June"

That is a bad "eg.". In Perl code, a double quoted string
interpolates, so the above is equivalent to the string:
q{This is charlie's company's May\June}

So I have no idea if that's the actual string you have, or if your real
string actually has a total of four slashes in it. And I have
absolutely no intention of guessing. This is why the Posting
Guidelines tell you to post a short but complete script, rather than
pseudo-code snippets, so we can see exactly what you're dealing with.
Everything I tried drops out the \ between MayJune also

And how can we help you understand what you're doing wrong if you won't
show us any of these attempts?
Anyhelp in this regex would be gratefully appreciated

And putting a little care into your post would be appreciated by those
from whom you're seeking help.

Paul Lalli
 
P

Paul Lalli

Jürgen Exner said:
Sorry for being dense, but those two strings are identical already.

I beg to differ.

$ cat clpm.pl
$x = "This is charlie\'s company\'s May\\June";
$y = "This is charlie's company's May\June";
print $x eq $y ? "Yes\n" : "No\n";

$ perl clpm.pl
No

"\'" is the same as "'", but "\\J" is not the same as "\J"

Paul Lalli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top