Unpack is even faster, for fixed-format strings.
dZ.
On Mar 24, 2006, at 22:19, Chris Wagner wrote:
At 10:38 AM 3/24/2006 -0700, Paul Rousseau wrote:
I am looking for help on a regex that examines strings such as
"xxxN yyy sssNNN"
"xxxN yyyNyyy sss"
"xxxN yyyNyyy ssN"
At 10:38 AM 3/24/2006 -0700, Paul Rousseau wrote:
> I am looking for help on a regex that examines strings such as
>
>"xxxN yyy sssNNN"
>"xxxN yyyNyyy sss"
>"xxxN yyyNyyy ssN"
>
>and returns only the sss part? N is always a numeral, and s is always
>alphabetic.
Do u have to examine
Try this:
$string =~ /^.{3}\d\s[^\s]+\s([a-zA-Z]+)\d+$/;
$prefix = $1;
That should match:
- any three characters at the beginning of the string: ^.{3}
- followed by a number: \d
- followed by whitespace: \s
- followed by any one or more characters until the next whitespace [^\s]+
-
Something like this :
/(\w\s){2}([a-zA-Z]+)\d*/
David
Joe Discenza wrote:
Paul Rousseau wrote, on Friday, March 24, 2006 12:38 PM
:I am looking for help on a regex that examines strings such as
:
: "xxxN yyy sssNNN"
: "xxxN yyyNyyy sss"
: "xxxN yyyNyyy ssN"
:
: and returns
Paul,
Give this a shot:
/^\w+\s+\w+\s+([A-Za-z]+)\d+/
A regex should be as explicit and exclusive as possible, so I would
remove the lowercase (a-z) portion of the character class if you know
for sure that the letters you want will always be uppercase.
-Brian
_
Bria
$string = "MBH1 WELL PIT050";
$string =~ s/.* (.*?)\d+/\1/; # Questionmark makes it
non-greedy
($prefix) = $string; # Didn't figure out how
to do ($prefix) = $string =~
print "$prefix";
<>;
**
Hello,
I am looking for help on a
[EMAIL PROTECTED] wrote:
> Hello,
>
>I am looking for help on a regex that examines strings such as
>
> "xxxN yyy sssNNN"
> "xxxN yyyNyyy sss"
> "xxxN yyyNyyy ssN"
>
> and returns only the sss part? N is always a numeral, and s is always
> alphabetic.
>
> Here is what I have so
Paul Rousseau wrote, on Friday, March 24, 2006 12:38 PM
:I am looking for help on a regex that examines strings such as
:
: "xxxN yyy sssNNN"
: "xxxN yyyNyyy sss"
: "xxxN yyyNyyy ssN"
:
: and returns only the sss part? N is always a numeral, and s
: is always alphabetic.
Does