Re: Simple regex problem has me baffled

2009-01-27 Thread Gunnar Hjalmarsson
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";

RE: Simple regex problem has me baffled

2009-01-27 Thread Bill Harpley
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

RE: Simple regex problem has me baffled

2009-01-27 Thread Bill Harpley
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

RE: Simple regex problem has me baffled

2009-01-27 Thread Bill Harpley
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

RE: Simple regex problem has me baffled

2009-01-27 Thread Bill Harpley
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

Re: Simple regex problem has me baffled

2009-01-26 Thread Rob Dixon
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 u

Re: Simple regex problem has me baffled

2009-01-26 Thread Gunnar Hjalmarsson
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,

Re: Simple regex problem has me baffled

2009-01-26 Thread John W. Krahn
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

Re: Simple regex problem has me baffled

2009-01-26 Thread Mr. Shawn H. Corey
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

Simple regex problem has me baffled

2009-01-26 Thread Bill Harpley
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 digit hex number contained in

Re: Simple Regex Problem.

2003-03-08 Thread Scott R. Godin
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

Re: Simple Regex Problem.

2003-03-07 Thread Rob Dixon
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/ <([^>]*)>

Re: Simple Regex Problem.

2003-03-07 Thread Scott R. Godin
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

Re: Simple Regex Problem.

2003-03-07 Thread Scott R. Godin
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

Re: Simple Regex Problem.

2003-03-05 Thread Rob Dixon
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

Re: Simple Regex Problem.

2003-03-05 Thread Paul Johnson
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]

Re: Simple Regex Problem.

2003-03-05 Thread Rob Dixon
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

Re: Simple Regex Problem.

2003-03-05 Thread Rob Dixon
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

RE: Simple Regex Problem.

2003-03-04 Thread Wagner, David --- Senior Programmer Analyst --- WGO
stop trapping text >> .* = anything, zero or more times >> $ = end of string >> /$1/ = replace matched text with the trapped text >> >> Rob >> >> -Original Message- >> From: Gregg R. Allen [mailto:[EMAIL PROTECTED] >> Sent: Tuesday, March

Re: Simple Regex Problem.

2003-03-04 Thread david
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

RE: Simple Regex Problem.

2003-03-04 Thread Beau E. Cox
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

Re: Simple Regex Problem.

2003-03-04 Thread Gregg R . Allen
ng text [^>]* = anything but ">", zero or more times )> = stop trapping text .* = anything, zero or more times $ = end of string /$1/ = replace matched text with the trapped text Rob -Original Message- From: Gregg R. Allen [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 04,

RE: Simple Regex Problem.

2003-03-04 Thread Hanson, Rob
PM To: [EMAIL PROTECTED] Cc: Gregg R. Allen Subject: Simple Regex Problem. So my boss just told me that he doesn't like the fact that the "From:" field in our email database typically looks like: "BlahBlahBlahBlah From: BlahsvilleDude <[EMAIL PROTECTED]>BlahBBla

Simple Regex Problem.

2003-03-04 Thread Gregg R . Allen
So my boss just told me that he doesn't like the fact that the "From:" field in our email database typically looks like: "BlahBlahBlahBlah From: BlahsvilleDude <[EMAIL PROTECTED]>BlahBBlahBBlah" (The "blahs", of course, are not literal, but can be anything.) He wants the subject field to look

Re: simple regex problem

2003-02-27 Thread Ramprasad
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

Re: simple regex problem

2003-02-27 Thread R. Joseph Newton
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

Re: simple regex problem

2003-02-27 Thread Ramprasad
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

simple regex problem

2003-02-26 Thread Ramprasad
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"; } else { pri