How to extract the file name from the string in Perl?

Posted on 2012-08-16
Last Modified: 2012-08-21
This is the string I am dealing with:

See 20120815_1543_Report.html for details in /dir1/dir2/dir3/dir4 directory.

Open in new window

How can I extract 20120815_1543_Report.html from this string?

Question by:Tolgar
    1 Comment
    LVL 31

    Accepted Solution

    my $str = 'See 20120815_1543_Report.html for details in /dir1/dir2/dir3/dir4 directory.';
    my ($html) = $str =~ /(\w+\.html)/;

    Open in new window


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    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…
    A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (,  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
    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…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    734 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

    22 Experts available now in Live!

    Get 1:1 Help Now