Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

stripslashes in perl

Posted on 2002-07-11
4
Medium Priority
?
1,348 Views
Last Modified: 2008-01-09
In Perl, how can I perform the same action that stripslashes does in php?
0
Comment
Question by:blackwolfsystems
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
smisk earned 225 total points
ID: 7147209
Shouldn't be too hard.  According to the php docs you just remove backslashes from \", \', and \\.

sub stripslashes() {

    $_ = shift();
    s/\\'/'/;
    s/\\"/"/;
    s/\\\\/\\/;

    return $_;

}
0
 

Author Comment

by:blackwolfsystems
ID: 7148673
Thanks I kind of guessed it would end up like that.

But that doesn't quite work, you have to do:
s/\\'/'/g;
s/\\"/"/g;
s/\\\\/\\/g;
instead as otherwise it only changes the first occurance.

Thanks for the help
0
 
LVL 1

Expert Comment

by:smisk
ID: 7149037
Thanks.  I must have missed the global option...
0
 
LVL 85

Expert Comment

by:ozo
ID: 7150909
s/\\([\\'"])/$1/g
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question