: 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
Bill Harpley wrote:
Hi Gunnar,
I tried your suggestions but had no luck :-(
(1) I tried your idea of using a paragraph separator
local $/ = ''; # paragraph mode
while ( my $entry = ) {
if ( $entry =~ /\[([a-z0-9]{5})]/ ) {
print "$1\n";
Can you explain why this works but my orginal effort did not?
Many thanks,
Bill Harpley
-Original Message-
From: Rob Dixon [mailto:rob.di...@gmx.com]
Sent: Monday, January 26, 2009 7:19 PM
To: Perl Beginners
Cc: Bill Harpley
Subject: Re: Simple regex problem has me baffled
Bill Harple
each record into a single long
line before trying to perform regex match? Is there an easy way to do
this?
Regards,
Bill Harpley
-Original Message-
From: Gunnar Hjalmarsson [mailto:nore...@gunnar.cc]
Sent: Monday, January 26, 2009 5:22 PM
To: beginners@perl.org
Subject: Re: Simple re
it:]] but to no avail
So I remain stuck at square one !!
Regards,
Bill
-Original Message-
From: John W. Krahn [mailto:jwkr...@shaw.ca]
Sent: Monday, January 26, 2009 5:20 PM
To: Perl Beginners
Subject: Re: Simple regex problem has me baffled
Bill Harpley wrote:
> Hello,
He
uch as 'print
"$1\n";' in other scripts.
Regards,
Bill Harpley
-Original Message-
From: Mr. Shawn H. Corey [mailto:shawnhco...@magma.ca]
Sent: Monday, January 26, 2009 4:32 PM
To: Bill Harpley
Cc: beginners@perl.org
Subject: Re: Simple regex problem has
Bill Harpley wrote:
> Hello,
>
> I have simple regex problem that is driving me crazy.
>
> I am writing a script to analyse a log file. It contains Java related
> information about requests and responses.
>
> Each pair of Request (REQ) and Response (RES) calls have a unique
> Request ID. This is
Bill Harpley wrote:
[2009-01-23 09:20:48,719]TRACE [server-1] [http-80-5] a...@mydomain.net
:090123-092048567:f5825 (SetCallForwardStatusImpl.java:call:54) -
RequestId [81e80] SetCallForwardStatus.REQ { accountNumber:=W12345,
phoneNumber:=12121212121, onBusyStatus:=true, busyCurrent:=voicemail,
Bill Harpley wrote:
Hello,
Hello,
I have simple regex problem that is driving me crazy.
I am writing a script to analyse a log file. It contains Java related
information about requests and responses.
Each pair of Request (REQ) and Response (RES) calls have a unique
Request ID. This is a 5 d
On Mon, 2009-01-26 at 16:20 +0100, Bill Harpley wrote:
> foreach $entry(@list)
> {
>
> $entry =~ /\[([a-z0-9]{5})\]/;
>
> print "$1\n"; # print to screen
>
> # print FILE "$1\n";# print to file
> }
If there is no match, you are printing a uninitiali
Hi George,
Are you looking for a TCL script or a PERL regex expression, if you are
using PERL
then try the code what Dmitry Motevich has written if u need in TCL then
try the below
---
set x "Linz_Untauglich Dr."
set result [regexp (_)(
George Homorozeanu am Mittwoch, 25. Januar 2006 16.12:
> I need it with RegEx, that's my problem.
>
> Thanks,
>
> George.
>
> "Xavier Noria" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
> news:[EMAIL PROTECTED]
>
> > On Jan 25, 2006, at 12:23, George Homorozeanu wrote:
> >> I am very new in RegEx and
Hello George,
Wednesday, January 25, 2006, 1:23:41 PM, you wrote:
GH> Hi,
GH> I am very new in RegEx and I want to be able to write an expresion that
does
GH> the following:
GH> Return all the characters from a string starting from the 5-th character.
GH> Given:
GH> Linz_Untauglich Dr.
GH>
I need it with RegEx, that's my problem.
Thanks,
George.
"Xavier Noria" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
> On Jan 25, 2006, at 12:23, George Homorozeanu wrote:
>
>> I am very new in RegEx and I want to be able to write an expresion that
>> does
>> the followin
> "George" == "George Homorozeanu" <[EMAIL PROTECTED]> writes:
George> Hi,
George> I am very new in RegEx and I want to be able to write an expresion that
does
George> the following:
George> Return all the characters from a string starting from the 5-th
character.
Call me paranoid, but th
On Jan 25, 2006, at 12:23, George Homorozeanu wrote:
I am very new in RegEx and I want to be able to write an expresion
that does
the following:
Return all the characters from a string starting from the 5-th
character.
You want to do it with a regexp for some particular reason? That's
t
Rob Hanson wrote:
>
> Try this...
>
> # untested
> $text =~ s/\[[^\]]+?\]/$1/g;
>
> [^\]] - means anything but a closing bracket
> +? - means 1 or more times (as few as possible)
Hi Rob
You're not capturing $1, so you would be replacing them and
their contents with 'undef'. (The opposite of what
On 4/15/2004 7:10 PM, [EMAIL PROTECTED] wrote:
How can I write a regular expression to keep the part of a string that's
between a pair of square braces? Here's a sample line:
Updating Wellbore Set Keys: [wlbr_id = 1234567890, data_provider_code =
MTBL, welltype = OIL]
use Text::Balanced; # includ
On Apr 15, 2004, at 6:22 PM, James Edward Gray II wrote:
On Apr 15, 2004, at 6:10 PM, [EMAIL PROTECTED] wrote:
How can I write a regular expression to keep the part of a string
that's
between a pair of square braces? Here's a sample line:
Updating Wellbore Set Keys: [wlbr_id = 1234567890, data
On Apr 15, 2004, at 6:10 PM, [EMAIL PROTECTED] wrote:
How can I write a regular expression to keep the part of a string
that's
between a pair of square braces? Here's a sample line:
Updating Wellbore Set Keys: [wlbr_id = 1234567890, data_provider_code =
MTBL, welltype = OIL]
Maybe:
s/^[^[]]*\[
In a message dated 4/15/2004 7:13:09 PM Eastern Daylight Time,
[EMAIL PROTECTED] writes:
>How can I write a regular expression to keep the part of a string that's
>between a pair of square braces? Here's a sample line:
>
>Updating Wellbore Set Keys: [wlbr_id = 1234567890, data_provider_code =
>MT
Try this...
# untested
$text =~ s/\[[^\]]+?\]/$1/g;
[^\]] - means anything but a closing bracket
+? - means 1 or more times (as few as possible)
Rob
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Sent: Thursday, April 15, 2004 7:11 PM
To: [EMAIL PROTECTED]
Subject:
Rob Dixon wrote:
>> you want to know what's failing, right?
>
> Wrong. John was just pointing out that $1 would remain
> defined from a previous regex match in my previous post.
> This would mean that there was no way of telling in
> retrospect if the match had suceeded. The context of
> the prob
Hi Scott.
Scott R. Godin wrote:
> Rob Dixon wrote:
>
> > Paul Johnson wrote:
> > > Rob Dixon said:
> > >
> > > > $data =~ m/ <([^>]*)> /x;
> > > > my $newdata = $1;
> > >
> > > And if the match fails?
> >
> > Well I think it's likely that you'd want to do:
> >
> > $data =~ m/ <([^>]*)>
Rob Dixon wrote:
> Paul Johnson wrote:
>> Rob Dixon said:
>>
>> > $data =~ m/ <([^>]*)> /x;
>> > my $newdata = $1;
>>
>> And if the match fails?
>
> Well I think it's likely that you'd want to do:
>
> $data =~ m/ <([^>]*)> /x or die "Malformed data";
>
> or at least:
>
> $data
David wrote:
> Gregg R . Allen wrote:
>
>> It was close but what I got is : "JohnDoe.com" Instead of
>> "[EMAIL PROTECTED]".
>>
>> I think it has something to do with escaping the "@" sign. I've been
>> experimenting, but without much luck.
>>
>
> that's because Perl thinks @Someplace is an
Paul Johnson wrote:
> Rob Dixon said:
>
> > $data =~ m/ <([^>]*)> /x;
> > my $newdata = $1;
>
> And if the match fails?
Well I think it's likely that you'd want to do:
$data =~ m/ <([^>]*)> /x or die "Malformed data";
or at least:
$data =~ m/ <([^>]*)> /x or next;
as a mismatch
Rob Dixon said:
> $data =~ m/ <([^>]*)> /x;
> my $newdata = $1;
And if the match fails?
--
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
David --- Senior Programmer Analyst --- Wgo Wagner wrote:
> I had to change as follows:
> my $data = 'BlahBlahBlahBlah From: BlahsvilleDude
> <[EMAIL PROTECTED]>BlahBBlahBBlah';
>
> printf "bf:%-s\n", $data;
>
> $data =~ s/^.*<([^>]*)>.*$/$1/gs;
>
> printf "af:%-s\n", $data;
>
> but it does work t
Rob Hanson wrote:
> Try this...
>
> my $data = "BlahBlahBlahBlah From: BlahsvilleDude
> <[EMAIL PROTECTED]>BlahBBlahBBlah"
> $data =~ s/^.*<([^>]*)>.*$/$1/;
Hi Rob.
Anchoring the search at the start of the string and then allowing
'any number of anything' is the same as not anchoring it! Likewis
Gregg R. Allen wrote:
> It was close but what I got is : "JohnDoe.com" Instead of
> "[EMAIL PROTECTED]".
>
> I think it has something to do with escaping the "@" sign. I've been
> experimenting, but without much luck.
>
> Thanks,
>
> Gregg
>
>
> On Tuesday, Mar 4, 2003, at 15:31 US/Mountain,
Gregg R . Allen wrote:
> It was close but what I got is : "JohnDoe.com" Instead of
> "[EMAIL PROTECTED]".
>
> I think it has something to do with escaping the "@" sign. I've been
> experimenting, but without much luck.
>
that's because Perl thinks @Someplace is an array. if you have warning
Hi -
> -Original Message-
> From: Gregg R. Allen [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, March 04, 2003 2:16 PM
> To: Hanson, Rob
> Cc: Gregg R. Allen; [EMAIL PROTECTED]
> Subject: Re: Simple Regex Problem.
>
>
> It was close but what I got is : "Jo
It was close but what I got is : "JohnDoe.com" Instead of
"[EMAIL PROTECTED]".
I think it has something to do with escaping the "@" sign. I've been
experimenting, but without much luck.
Thanks,
Gregg
On Tuesday, Mar 4, 2003, at 15:31 US/Mountain, Hanson, Rob wrote:
Try this...
my $data =
Try this...
my $data = "BlahBlahBlahBlah From: BlahsvilleDude
<[EMAIL PROTECTED]>BlahBBlahBBlah"
$data =~ s/^.*<([^>]*)>.*$/$1/;
Broken down...
s/ = substitute
^ = beginning of string
.* = anything, zero or more times
< = "<"
( = start trapping text
[^>]* = anything but ">", zero or more times
)
R. Joseph Newton wrote:
Ramprasad wrote:
hello all,
I have a file read into a single string, and I want to write a regex
that will tell me wether the file contains any non hashed line
__DATA__
## FORWARD
## FORWARD
## VACATION
## VACATION
__END__
But my regex fails in case of any blank lines o
Ramprasad wrote:
> hello all,
>
> I have a file read into a single string, and I want to write a regex
> that will tell me wether the file contains any non hashed line
>
> __DATA__
> ## FORWARD
> ## FORWARD
> ## VACATION
> ## VACATION
> __END__
>
> But my regex fails in case of any blank lines or
Ramprasad wrote:
hello all,
I have a file read into a single string, and I want to write a regex
that will tell me wether the file contains any non hashed line
This is my test script
#!/usr/bin/perl
#
{
local($/)=undef;
$str=;
}
print $str;
if($str=~/^\s*[^#]/m){
print "NOT ENTIRELY COMMENT
On Nov 20, Marco Centemeri said:
>How can I know if a variable is exactly 6 digit long?
if ($str =~ /\A\d{6}\z/) { ... }
The \A matches the beginning of the string, \d{6} matches 6 digits, and
the \z matches the end of the string.
If you meant "characters" instead of "digits", don't use a reg
perldoc -f length
http://danconia.org
On Wed, 20 Nov 2002 16:03:35 +0100, Marco Centemeri <[EMAIL PROTECTED]> wrote:
> Hi All!!
>
> How can I know if a variable is exactly 6 digit long?
>
> I tried:
>
>$myvar='ABCDEF';
>if ($myvar =~ /
Lance Murray wrote:
>
> Hello
Hello,
> I'm trying to write a simple script to test if a port is up or down. It all
> depends on being able to parse for the word "Connected" in an array. Try as
> I might, I can't figure out why the following regex comparison won't work.
Perhaps you need the
Hi -
1) try: if ($reply[1] =~ /Connected/) { ...
I _think_ w/o parens, Perl says:
if $reply[1] => true
true =~ /Connected/ => false
(you also may have to have the m in m/Connected/
2) whole array:
for (@reply) {
if (/Connected/) {
... OK ...
last;
}
}
3) after having read
On Oct 16, Lance Murray said:
>#!/bin/perl
You should get used to using 'strict' and warnings
#!/bin/perl -w
use strict;
>$host = @ARGV[0];
That should be $ARGV[0].
>$port = @ARGV[1];
Why not:
my ($host, $port) = @ARGV;
>@reply = `echo " " | telnet $host $port`;
>if $reply[1] =~ /Co
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
Yes, I am in fact changing the template file. Personally my first experience
with CGI::FastTemplate has made me wish it were a bit more flexible, but
I suppose it's certainly conceivable that the flexibility is there and I
just haven't found it based on what I read in perldoc.
-Ian
-- Original
On Jan 10, [EMAIL PROTECTED] said:
>>Personally, I find that odd -- moving from an array of 21 elements to 21
>>DIFFERENT scalars?!
>
>You're right, it is odd. But unless I've missed how to take a populated
>array and create a usable hash from it to pass to CGI::FastTemplate, this
>is what I bel
Jeff et al,
>>I have a file which has many strings like "$something[0]" through
>>"something[20]" amongst other text (quotes only provided here for
>>clarity).
>>
>>What I want to do is replace these strings with: "$SOMETHING0" through
>>"$SOMETHING20".
>
>Personally, I find that odd -- moving fr
On Jan 10, [EMAIL PROTECTED] said:
>I have a file which has many strings like "$something[0]" through
>"something[20]" amongst other text (quotes only provided here for
>clarity).
>
>What I want to do is replace these strings with: "$SOMETHING0" through
>"$SOMETHING20".
Personally, I find that o
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
74 matches
Mail list logo