: beginners@perl.org
Subject: Re: Simple regex question
You wrote on 05/19/2009 03:18 PM:
> Simple question for the regEXperts out there...
>
> I have a string that is always in the format: a.nn+x.y
>
> a is always 5 chars
> n can be 1 or 2 digits
> x can be +/- (with sign), 1-4
Dan Fish wrote:
Simple question for the regEXperts out there...
I have a string that is always in the format: a.nn+x.y
a is always 5 chars
[a-zA-Z0-9]{5}
n can be 1 or 2 digits
[0-9]{1,2}
x can be +/- (with sign), 1-4 digits
[-+][0-9]{1,4}
y is always positive (no sign), 1
Chas. Owens wrote:
On Tue, May 19, 2009 at 09:55, Alexander Koenig wrote:
snip
($a,$n,$x,$y)) = $item =~ /(.{5})\.(\d\d?)[-+](\d{1,4})\.(\d{1,4})/;
snip
As of Perl 5.8 \d no longer matches [0-9].
^
As of Perl 5.8 \d no longer matches only [0-9].
Dan Fish wrote:
Simple question for the regEXperts out there...
I have a string that is always in the format: a.nn+x.y
a is always 5 chars
[a-zA-Z0-9]{5}
n can be 1 or 2 digits
[0-9]{1,2}
x can be +/- (with sign), 1-4 digits
[-+][0-9]{1,4}
y is always positive (no sign), 1
On Tue, May 19, 2009 at 10:21, Alexander Koenig wrote:
> Chas. Owens wrote on 05/19/2009 04:02 PM:
>
>>> ($a,$n,$x,$y)) = $item =~ /(.{5})\.(\d\d?)[-+](\d{1,4})\.(\d{1,4})/;
>> snip
>>
>> As of Perl 5.8 \d no longer matches [0-9]. It now matches any UNICODE
>> character that has the digit propert
Chas. Owens wrote on 05/19/2009 04:02 PM:
>> ($a,$n,$x,$y)) = $item =~ /(.{5})\.(\d\d?)[-+](\d{1,4})\.(\d{1,4})/;
> snip
>
> As of Perl 5.8 \d no longer matches [0-9]. It now matches any UNICODE
> character that has the digit property. This includes characters such
> as "\x{1815}" (MONGOLIAN DI
> > Simple question for the regEXperts out there...
> >
> > I have a string that is always in the format: a.nn+x.y
> >
> > a is always 5 chars
> > n can be 1 or 2 digits
> > x can be +/- (with sign), 1-4 digits
> > y is always positive (no sign), 1-4 digits
> snip
>
> What do you mean by char
A crude one
($part,$unit,$x,$y,$xlen,$ylen) = ($1,$2,$3,length($4),length($5))
if ($string =~ /(^\S{5})\.(\d{2})([+-])(\d+)\.(\d+)$/);
-Original Message-
From: Dan Fish [mailto:d...@ninemoons.com]
Sent: 19 May 2009 14:18
To: beginners@perl.org
Subject: Simple regex question
Simple que
On Tue, May 19, 2009 at 09:55, Alexander Koenig wrote:
snip
> ($a,$n,$x,$y)) = $item =~ /(.{5})\.(\d\d?)[-+](\d{1,4})\.(\d{1,4})/;
snip
As of Perl 5.8 \d no longer matches [0-9]. It now matches any UNICODE
character that has the digit property. This includes characters such
as "\x{1815}" (MONGO
On Tue, May 19, 2009 at 09:18, Dan Fish wrote:
> Simple question for the regEXperts out there...
>
> I have a string that is always in the format: a.nn+x.y
>
> a is always 5 chars
> n can be 1 or 2 digits
> x can be +/- (with sign), 1-4 digits
> y is always positive (no sign), 1-4 digits
snip
You wrote on 05/19/2009 03:18 PM:
> Simple question for the regEXperts out there...
>
> I have a string that is always in the format: a.nn+x.y
>
> a is always 5 chars
> n can be 1 or 2 digits
> x can be +/- (with sign), 1-4 digits
> y is always positive (no sign), 1-4 digits
The best I ca
11, 2002 8:26 AM
To: Bob Showalter; [EMAIL PROTECTED]
Subject: RE: Simple RegEx Question
Thanks Nikola and Bob.
Would "anchoring with \z" tantamount to having a
trailing "$"? In other words, are the following
expressions one and the same?
/^[0-9a-fA-F]+\z/
/^[0-9a-fA-F]+$/
_
Thanks Nikola and Bob.
Would "anchoring with \z" tantamount to having a
trailing "$"? In other words, are the following
expressions one and the same?
/^[0-9a-fA-F]+\z/
/^[0-9a-fA-F]+$/
__
Yahoo! - We Remember
9-11: A tribute to the more than 3
ola Janceski; [EMAIL PROTECTED]
Subject: RE: Simple RegEx Question
use strict;
while(){
chomp;
if(/[^0-9a-fA-F]+/){
print("$_ is not a hexadecimal number!\n");
}else{
print("$_ is a hexadecimal number!\n");
}
}
__DATA__
f4dxf
ffaa99
gxad
2832
2842da
--- N
use strict;
while(){
chomp;
if(/[^0-9a-fA-F]+/){
print("$_ is not a hexadecimal number!\n");
}else{
print("$_ is a hexadecimal number!\n");
}
}
__DATA__
f4dxf
ffaa99
gxad
2832
2842da
--- Nikola Janceski <[EMAIL PROTECTED]>
wrote:
> give us a snippet of your code. you made a mist
> -Original Message-
> From: RTO RTO [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 11, 2002 11:00 AM
> To: [EMAIL PROTECTED]
> Subject: Simple RegEx Question
>
>
> Here is a RegEx that I am using to check if the given
> string is Hexadecimal or not.
>
> /[^0-9a-fA-F]+/ #if t
give us a snippet of your code. you made a mistake somewhere.
and give us examples of what the variables contain.
-Original Message-
From: RTO RTO [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 11, 2002 11:09 AM
To: Nikola Janceski; [EMAIL PROTECTED]
Subject: RE: Simple RegEx
I am afraid, your suggestion is even breaking for
already working ones! i.e., it says HEXADECIMAL NUMBER
for an invalid string like "f4dx" and also says
HEXADECIMAL NUMBER for invalid empty strings.
The one I had posited,without the leading "^" and "$"
matched for all the cases correctly, except
see below
/^[^0-9a-fA-F]+$/ #if this evals to true string is NOT
## start of string ^ and end of string $
-Original Message-
From: RTO RTO [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 11, 2002 11:00 AM
To: [EMAIL PROTECTED]
Subject: Simple RegEx Question
Here is a RegEx tha
Ah... i see.
in scalar context, it returns false until left is true. then returns true
until right is true.
just what we want. very handy.
thanks.
On Saturday, March 30, 2002, at 11:48 AM, Jenda Krynicky wrote:
> From: bob ackerman <[EMAIL PROTECTED]>
>> sorry. still in dark.
>
From: bob ackerman <[EMAIL PROTECTED]>
> sorry. still in dark.
> what exactly does '/START_KEYWORD/.../END_KEYWORD/' mean?
> I see a regex -> /START_KEYWORD/
> an ellipsis -> ...
> and a regex -> /END_KEYWORD/
> you are saying the whole thing means something, but I don't underst
sorry. still in dark.
what exactly does '/START_KEYWORD/.../END_KEYWORD/' mean?
I see a regex -> /START_KEYWORD/
an ellipsis -> ...
and a regex -> /END_KEYWORD/
you are saying the whole thing means something, but I don't understand
what.
you say 'the elipsis returns false'
what does that mean? w
From: bob ackerman <[EMAIL PROTECTED]>
> i don't understand your answer. how will that match anything?
> the first line matches the whole block ok, but then the match is
> dropped by the '!' phrases since they are in the text. also, where is
> documented the ellipsis in a grep?
i don't understand your answer. how will that match anything?
the first line matches the whole block ok, but then the match is dropped
by the '!' phrases
since they are in the text.
also, where is documented the ellipsis in a grep?
also, using two regexes on either side of the ellipsis?
On Satu
From: Rob Lee <[EMAIL PROTECTED]>
> I'm parsing a file with multiple Fortran-like blocks that look like:
> START_KEYWORD
> line 1
> line 2
> END_KEYWORD
>
> I want only the contents of each block, not the keywords.
>
> grep { /START_KEYWORD/.../END_KEYWORD/ }
> returns
Sorry. Ignore that. It's 5:30 and home time. What can I say.
Use this instead.
$dnvalue =~ /CN=(\w*)/;
$username = $1;
print $username
-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 28 June 2001 17:31
To: 'Mike Ring'; [EMAIL PROTECTED]
Subject: R
There's no need to match past the CN=, then prepend the CN= back to the
string. Use the following
$dnvalue = "CN=foo,OU=bar,O=pah";
$dnvalue =~ /(CN=[A-Za-z0-9]*)/;
$username = $1;
print $username
This looks for CN= followed by any number of letters (upper or lowercase)
and numbers. If you don'
--- Mike Ring <[EMAIL PROTECTED]> wrote:
> I've learned a bit about regular expressions today. I have a string
> formatted
> like "CN=foo,OU=bar,O=pah" and I need to parse out "foo". I have
> created the
> following code which does work:
>
> $dnvalue =~ m/([^,]*)/;
> $username = $1;
> $username
28 matches
Mail list logo