Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
my $string = '~/tmp/hfj/abc/bhd/5009.xmlreal.xml'; $string =~ s/^.*\/\d+//; print "$string\n";

Another way is to use File::Basename to extract the file name, and then remove the bits you don't want.

use File::Basename; $string = '~/tmp/hfj/abc/bhd/5009.xmlreal.xml'; my ($filename, $directories, $suffix) = fileparse($string); $filename =~ s/^\d+//; print "$filename\n";

Cheers,
Darren


In reply to Re: regular expression by McDarren
in thread regular expression by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    [Corion]: No, or I don't remember the story ;)
    LanX my favourite don't tell me the proof of concept is good enough for production anecdote
    [ambrus]: ah, it's one of thos
    [Eily]: what, there's a difference between proof of concept and production?
    [LanX]: 20 years ago traders were complaining about the latency of the trading system...
    [ambrus]: I'm currently in the process of rewriting my proof of concept programs. They sort of developped organically as I was experimenting, so now I've got an ugly mess of multiple programs and one-liners held together by nothing. I'll have to rewrite them to som
    [ambrus]: ething that's both cleanly organized and mostly automated.
    LanX in train, bad connection
    [Corion]: ambrus: Yeah - we're in that situation too, except that there is no time to do the reorganizing :-/

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (15)
    As of 2017-03-29 11:47 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Should Pluto Get Its Planethood Back?



      Results (350 votes). Check out past polls.