Perl Regular Expression?

Posted on 2011-05-12
Last Modified: 2012-05-11
So I have a string that is always contains general. and is following by some text and number. I need a regular expression to remove the general. and only leave anything after the period.
$before = general.XXXXX
Some regular expression that will remove general.
$after = XXXXX

Open in new window

Question by:KGNickl
    LVL 31

    Accepted Solution

    $before = 'general.XXXXX';

    $before =~ m/general\.(.*)/;

    $after = $1;
    LVL 31

    Expert Comment

    This would also work

    my $before = 'general.XXXXX';
    my ($after) = $before  =~ m/general\.(.*)/;

    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

    I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
    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…
    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…

    728 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

    20 Experts available now in Live!

    Get 1:1 Help Now