Perl Regular Expression

Posted on 2011-05-10
Last Modified: 2012-05-11
Have a Tk function that lets a user select a file. Its returning the a path format that will not work in windows/perl for my program. I need to take the path I'm getting back and reformat it. So any / are replaced with \\

How its returned to me: R:/Project 2/Project 2.rqs
How I need it to be: R:\\Project\\Project 2.rqs
Question by:KGNickl
    LVL 31

    Accepted Solution

    Suppose it is sorted in variable $url, then perl RE would be
    $url =~ s/\//\\\\/g;
    LVL 10

    Assisted Solution

    or  $url =~ s:/:\\\\:g;
    LVL 5

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Whatever be the reason, if you are working on web development side,  you will need day-today validation codes like email validation, date validation , IP address validation, phone validation on any of the edit page or say at the time of registration…
    As most anyone who uses or has come across them can attest to, regular expressions (regex) are a complicated bit of magic. Packed so succinctly within their cryptic syntax lies a great deal of power. It's not the "take over the world" kind of power,…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    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…

    760 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

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now