~ substitute ' with `

B

BJ

We are trying to get a text area from screen and edit it to
replace ' with ` (to preent mysql record mark conflict) $title is could be
blank initially

$title = ~s/'/`/g ;
or even
$title =~s\/'/\`/g ;

Results "4294967295" for the value of $title !

Can anyone suggest a work arround.

Thanks for any comments.

Regards
BJ
 
U

Uri Guttman

B> We are trying to get a text area from screen and edit it to
B> replace ' with ` (to preent mysql record mark conflict) $title is could be
B> blank initially

B> $title = ~s/'/`/g ;

that is very wrong as the op is =~ with no space. you assigned $title
the negation of the s/// op result which was likely 0 and it inverted it
to all 1's which is the number you got.
B> or even
B> $title =~s\/'/\`/g ;

here you have the op correct but the s\/ is insane. i am not even sure
if that parses.

B> Can anyone suggest a work arround.

fix your op and learn to not put spaces inside perl's ops.

uri
 
B

BJ

Sorry, no good the same result.
Problem was extras space in between between "= ~" should be "=~"
Thanks
..
 
B

BJ

Thanks for the clue.

Problem was extras space in between between "= ~" should be "=~"

Works fine Now.
 
U

Uri Guttman

B> Sorry, no good the same result.

learn to bottom post which is the proper style here. you acknowledged one clue
from me so do it again.

that is actually a better and faster solution to your original
problem. and it does work. tr/// is meant for character processing vs s///
which is for strings and regexes. your problem was replacing ' with `
which is exactly what tr/// is for.

uri
 
E

Eric Pozharski

*SKIP*
B> $title =~s\/'/\`/g ;

here you have the op correct but the s\/ is insane. i am not even sure
if that parses.

It doesn't

Substitution replacement not terminated at -e line 1.

*CUT*
 

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,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top