Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: REGEX omit dashes - simple but ...

by AnomalousMonk (Archbishop)
on Apr 04, 2016 at 17:32 UTC ( #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?

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (1)
As of 2023-09-24 03:19 GMT
Find Nodes?
    Voting Booth?

    No recent polls found