On 11-12-29 02:45 PM, Chris Stinemetz wrote:
On Thu, Dec 29, 2011 at 1:17 PM, Xi Chen<cxde...@gmail.com> wrote:
Hello everyone,
I have a question about how to translate the meaning of ".+?". Please
see the examples below:
SASI_Hs01_00205058 HUMAN NM_005762 857 MISSION® siRNA 2
140.00
I want to get number"857", I found the command below works:
perl -ne 'if (/(SASI\w+)(.+?)\s(\d+)\s/) { print "$3\n"; }'
but ".+" or ".*"doesn't work. I don't know why "?" is so important?
I believe it makes the grouping optional.
Match 1 or 0 times
Sorry, no. It means a minimum span.
Given 'SASI_Hs01_00205058 HUMAN NM_005762 857 MISSION®
siRNA 2'
/(SASI\w+)(.+?)\s/ matches 'SASI_Hs01_00205058 '
/(SASI\w+)(.+)\s/ matches 'SASI_Hs01_00205058 HUMAN NM_005762
857 MISSION® siRNA '
To simplify things, try: if( /(?:SASI).*?\b(\d+)\b/ ){ print "$1\n"; ]
--
Just my 0.00000002 million dollars worth,
Shawn
Programming is as much about organization and communication
as it is about coding.
Never give up your dreams. Give up your goals, plans,
strategy, tactics, and anything that's not working but never
give up your dreams.
http://www.youtube.com/watch?v=cM5A1K6TxxM
"Never, never, never give up."
Winston Churchill
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/