Hello! I am trying to extract the protocol number which is alpha-numeric from a given string. My string is:
my $str="Study Protocol No. NBXF317N2201"; For this string, I'm trying to extract the term: using the following regular expression:
my ($prot) = $str =~ /Protocol (?:No\.? )?([A-Z0-9]{12})/;
This works fine. However, for some docs, I have the string "Number" instead of No. or No
For this: I tried to use matching within the expression like this:
my ($term) = $str =~ /Protocol (?:(No\.|Number)? )?([A-Z0-9]{12})/;
This just returns "Number" instead of: NBXF317N2201
So, given a string:"Study Protocol (No.|No|Number) NBXF317N2201", how can I modify my expression in order to extract NBXF317N2201 which is always a combination of alpha-and numbers and is always 12 characters long?
Thanks a lot in advance. Regards,madbee
In reply to Extract pattern from string by madbee
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |