Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: REGEX omit dashes - simple but ...

by AnomalousMonk (Archbishop)
on Apr 04, 2016 at 17:32 UTC ( [id://1159524]=note: print w/replies, xml ) Need Help??


in reply to REGEX omit dashes - simple but ...

... the code extracts everything prior to the first dash. I need the entire expression ...

I don't know if | Evidently you're still stuck on the "extraction" part, but if so, something like this might work:

c:\@Work\Perl\monks>perl -wMstrict -le "my $line = qq{foo \n ACCESSION NUMBER: 0001144204-09-017358 bar}; print qq{[[$line]]}; ;; my $rx_acc_num = qr{ \d+ (?: - \d+)* }xms; ;; my $acc_num; if ($line =~ m{ ^ \s* ACCESSION \s* NUMBER: \s* ($rx_acc_num) }xms) { $acc_num = $1; $acc_num =~ tr/-//d; } print qq{'$acc_num'}; " [[foo ACCESSION NUMBER: 0001144204-09-017358 bar]] '000114420409017358'

Update: Please see perlre, perlretut, and perlrequick.


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^2: REGEX omit dashes - simple but ...
by Anonymous Monk on Apr 04, 2016 at 17:49 UTC
    Sorry for OT but how do you accomplish the multiline commands in the command prompt under windows? I tried it many times, it should work with caret symbol at the end of a line but in my case (Windows 10) it does not. Thank you!

      The app I use is the first | second thing in my scratchpad, originally addressed to Athanasius. Please pay attention to the "shortcomings" section. The whole point originally was to quickly copy some brief code to the Windows clipboard, maybe edit it there with a clipboard editor, then paste it into a command-line window and see if it runs. I think my approach today would be different, but if you feel you could use it or any part of it, please feel free. (Update: The app runs on Windows 7 and I think I had it running on XP originally. What happens on 8 or 10 is anybody's guess.)


      Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-25 06:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found