Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: Regex Help

by 2teez (Priest)
on Mar 28, 2013 at 06:21 UTC ( #1025860=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Regex Help
in thread Regex Help

then change this print $1,$/ if/(\D+?)\d+?/;
to
this print $1,$/ if/(.+?)\s+?\d+?/;

UPDATE:
In case, you have all these data in the same file you can try this:

use strict; use warnings; while(<DATA>){ chomp; print $1,$/ if/(.+?)(\s+)?\d+?$/; } __DATA__ piratesofcareebian100 pirates of careebian100 pirates of careebian 100 pirates1 of careebian 100 pirates2 of careebian 100 pirates3 of careebian 100

Output
piratesofcareebian pirates of careebian pirates of careebian pirates1 of careebian pirates2 of careebian pirates3 of careebian
Please, check the reference I mentioned in my first post on this thread.
Hope that helps

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me


Comment on Re^3: Regex Help
Select or Download Code
Re^4: Regex Help
by Anonymous Monk on Mar 28, 2013 at 07:56 UTC
    Thanks 2Teez. That was clear & fine... :)

      How about "everything from pirates to careebian" ? ;-)

      use strict; use warnings; while(<DATA>){ chomp; print $1,$/ if /(pirates.*careebian)/; } __DATA__ piratesofcareebian100 pirates of careebian100 pirates of careebian 100 pirates1 of careebian 100 pirates2 of careebian 100 pirates3 of careebian 100

        How about "everything from pirates to careebian" ?
        But what about if the wording of the OP changes? Then your solution would no longer be useful.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1025860]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2014-12-25 20:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (163 votes), past polls