Re: Help required to extract multiple text fields from a text string

2012-05-27 Thread Michael Rasmussen
On Sun, May 27, 2012 at 07:24:26PM -0700, John W. Krahn wrote: > Michael Rasmussen wrote: >> [ a bunch of blather, snipped here ] > > The regular expression is not splitting! It is capturing. > split removes whitespace. > The regular expression captures non-whitespace. > So the two expressions pos

Re: Help required to extract multiple text fields from a text string

2012-05-27 Thread John W. Krahn
Michael Rasmussen wrote: On Sat, May 26, 2012 at 05:52:19PM +0100, Rob Dixon wrote: On 26/05/2012 14:07, pa...@fsmail.net wrote: From: "Rob Dixon" On 26/05/2012 13:51, pa...@fsmail.net wrote: split is slower than the correct regex matching. That is complete nonsense. Can you show a bench

Re: Help required to extract multiple text fields from a text string

2012-05-27 Thread Michael Rasmussen
On Sat, May 26, 2012 at 05:52:19PM +0100, Rob Dixon wrote: > On 26/05/2012 14:07, pa...@fsmail.net wrote: >> From: "Rob Dixon" >>> On 26/05/2012 13:51, pa...@fsmail.net wrote: split is slower than the correct regex matching. >>> >>> That is complete nonsense. Can you show a benchmark tha

Re: Help required to extract multiple text fields from a text string

2012-05-27 Thread Shawn H Corey
On 12-05-27 02:00 AM, Shlomi Fish wrote: On Sat, 26 May 2012 20:26:14 -0700 Adams Paul wrote: > > Sent from my LG phone > Why have you already sent 4 messages to this mailing list, which contain nothing except this "Sent from my LG phone" notice and the entire replied-to message quoted below

Re: Help required to extract multiple text fields from a text string

2012-05-26 Thread Shlomi Fish
Hi Paul, On Sat, 26 May 2012 20:26:14 -0700 Adams Paul wrote: > > Sent from my LG phone > Why have you already sent 4 messages to this mailing list, which contain nothing except this "Sent from my LG phone" notice and the entire replied-to message quoted below (with only a plain text part)? I

Re: Help required to extract multiple text fields from a text string

2012-05-26 Thread Adams Paul
Sent from my LG phone Jim Gibson wrote: > >On May 26, 2012, at 5:51 AM, pa...@fsmail.net wrote: > >> split is slower than the correct regex matching. >> > >Did you know that split uses a regular expression to find the separators on >which to split the string? So your claim is unlikely to be t

Re: Help required to extract multiple text fields from a text string

2012-05-26 Thread Chris Charley
""Christopher Gray"" wrote in message news Good day, I have a text file containing records. While I can extract single sub-strings, I cannot extract multiple sub-strings. The records are of multiple types - only about a third of which have the data I need. An example of a "good" record is A

RE: Help required to extract multiple text fields from a text string

2012-05-26 Thread Christopher Gray
Brilliant - a first class "teach-in". Many thanks for the description - it all works. Brilliant. -Original Message- From: Rob Dixon [mailto:rob.di...@gmx.com] Sent: 26 May 2012 2:13 PM To: beginners@perl.org Cc: Christopher Gray Subject: Re: Help required to extract mul

Re: Help required to extract multiple text fields from a text string

2012-05-26 Thread Rob Dixon
On 26/05/2012 14:07, pa...@fsmail.net wrote: From: "Rob Dixon" On 26/05/2012 13:51, pa...@fsmail.net wrote: split is slower than the correct regex matching. That is complete nonsense. Can you show a benchmark that supports your claim? There are many cases prove that, I am just lazy to fin

Re: Help required to extract multiple text fields from a text string

2012-05-26 Thread Jim Gibson
On May 26, 2012, at 5:51 AM, pa...@fsmail.net wrote: > split is slower than the correct regex matching. > Did you know that split uses a regular expression to find the separators on which to split the string? So your claim is unlikely to be true. In any case, the difference between using spli

Re: Help required to extract multiple text fields from a text string

2012-05-26 Thread Rob Dixon
On 25/05/2012 21:51, Christopher Gray wrote: Good day, I have a text file containing records. While I can extract single sub-strings, I cannot extract multiple sub-strings. The records are of multiple types - only about a third of which have the data I need. An example of a "good" record is

Re: Help required to extract multiple text fields from a text string

2012-05-26 Thread pangj
There are many cases prove that, I am just lazy to find one. You don't know it, so it's nonsense? Message Received: May 26 2012, 01:58 PM From: "Rob Dixon" To: beginners@perl.org Cc: pa...@fsmail.net Subject: Re: Help required

Re: Help required to extract multiple text fields from a text string

2012-05-26 Thread Rob Dixon
On 26/05/2012 13:51, pa...@fsmail.net wrote: split is slower than the correct regex matching. That is complete nonsense. Can you show a benchmark that supports your claim? Rob -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org h

Re: Help required to extract multiple text fields from a text string

2012-05-26 Thread pangj
split is slower than the correct regex matching. Message Received: May 26 2012, 10:59 AM From: "Dr.Ruud" To: beginners@perl.org Cc: Subject: Re: Help required to extract multiple text fields from a text string On 2012-05-25 22:51, C

Re: Help required to extract multiple text fields from a text string

2012-05-26 Thread Dr.Ruud
On 2012-05-25 22:51, Christopher Gray wrote: I have a text file containing records. While I can extract single sub-strings, I cannot extract multiple sub-strings. Try split, see perldoc -f split. while ( my $line= <$fh_in> ) { my @data= split ' ', $line; ; } --

Re: Help required to extract multiple text fields from a text string

2012-05-26 Thread timothy adigun
Hi Chris, On Sat, May 26, 2012 at 8:14 AM, Christopher Gray < christopher.g...@talktalk.net> wrote: > Hi, > > Thank you for looking to help me. Unfortunately, when I used your code > nothing was extracted. At least when I printed $1 nothing appeared. > > In order to help me learn more about Per

RE: Help required to extract multiple text fields from a text string

2012-05-26 Thread Christopher Gray
ay 2012 11:53 PM To: Christopher Gray; beginners@perl.org Subject: RE: Help required to extract multiple text fields from a text string May you try this matching? while() { next unless /^(\S+\s+)(\S+\s+)(\S+\s+).*\"(.*?)\"/; print "$1 $2 $3 $4\n"; } HTH. ===

Re: Help required to extract multiple text fields from a text string

2012-05-25 Thread timothy adigun
Hi Chris, On Fri, May 25, 2012 at 11:53 PM, wrote: > > May you try this matching? > > while() { >next unless /^(\S+\s+)(\S+\s+)(\S+\s+).*\"(.*?)\"/; >print "$1 $2 $3 $4\n"; > } > > HTH. > > > Message Received: May 25 2012, 09:52 PM > From: "Chri

RE: Help required to extract multiple text fields from a text string

2012-05-25 Thread pangj
May you try this matching? while() { next unless /^(\S+\s+)(\S+\s+)(\S+\s+).*\"(.*?)\"/; print "$1 $2 $3 $4\n"; } HTH. Message Received: May 25 2012, 09:52 PM From: "Christopher Gray" To: beginners@perl.org Cc: Subject: Help required to ex