Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 6th, 2001, 04:36 AM
vdschoor vdschoor is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 1999
Location: California
Posts: 43 vdschoor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 10
Regular Expressions....

Hi,

I need a regular expression that replaces all backslashes in a string with double backslashes.
In fact I want to use it in JavaScript, but as Perl is the real text search and replace language I thought I'd ask it here.

I think my regular expression to detect the backslashes should be something like this : ////
But I don't know if this detects all the occurrences of the backslash in the string.

Any help on this would be highly appreciated!

Thanks,
Iwan

Reply With Quote
  #2  
Old July 6th, 2001, 05:00 AM
jacylee jacylee is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: seoul, korea
Posts: 0 jacylee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
one of the solutions are ....

Hi, vdschoor

The following codes will work. I tested myself!
and backslash is \ not / isn't it ? ^^;

#!/usr/bin/perl
$tar = "ja\\ja\\";
print $tar;
print "\n";
$tar =~ s/\\/\\\\/g;
print $tar;
exit;

The result is

ja\ja\
ja\\ja\\

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Regular Expressions....


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT