Re: Regex sending me mad

2012-07-28 Thread Dr.Ruud
On 2012-07-27 17:43, Andy Bach wrote: On Fri, Jul 27, 2012 at 10:22 AM, Dr.Ruud wrote: On 2012-07-27 16:58, Andy Bach wrote: if ($model=~/(\S+)\s+(.*)\s*$/) { The \s* in the end does nothing. Well, I was thinking if it's a multi-word second match: v6 Austin Martin Then that would mat

Re: Regex sending me mad

2012-07-27 Thread Andy Bach
On Fri, Jul 27, 2012 at 10:22 AM, Dr.Ruud wrote: > On 2012-07-27 16:58, Andy Bach wrote: > >> if ($model=~/(\S+)\s+(.*)\s*$/) { > > > The \s* in the end does nothing. Well, I was thinking if it's a multi-word second match: v6 Austin Martin Then that would matches the rest of the phrase and tri

SOLVED Re: Regex sending me mad

2012-07-27 Thread Gary Stainburn
On Friday 27 July 2012 15:58:07 Andy Bach wrote: > Your RE is a bit odd - all that 'non-greedy *' -ness implies troubles. > The first "space star ?" can be greedy, right? You want all the > spaces/white space in a row, or rather don't want - as you're anchored > on the end, this doesn't do anythi

Re: Regex sending me mad

2012-07-27 Thread Dr.Ruud
On 2012-07-27 16:58, Andy Bach wrote: if ($model=~/(\S+)\s+(.*)\s*$/) { The \s* in the end does nothing. Closer: /(\S+)\s+(.*\S)/ Then play with this: perl -Mstrict -we' my $data= $ARGV[0] ? q{Ford} : qq{ \t Fiat Ulysse 2.1 TD}; printf qq{<%s> <%s>\n}, split( q{ }, $data, 2 )

Re: Regex sending me mad

2012-07-27 Thread Andy Bach
On Fri, Jul 27, 2012 at 9:04 AM, Gary Stainburn wrote: > print STDERR "About to split '$model'\n"; > if ($model=~/ *?(\w*) (.*?) *$/) { > $enqmake=lc($1); > $model=$2; > print STDERR "model split into '$enqmake' '$model'\n"; > } > } # extract make > > This generates: > > enqmake=

Re: Regex sending me mad

2012-07-27 Thread Shawn H Corey
On Fri, 27 Jul 2012 07:29:13 -0700 Jim Gibson wrote: > Why aren't you using the split function? > > ($model,$engmake) = split(' ',$model); That would be: ($model,$engmake) = split(' ',$model, 2); See `perldoc -f split` for details. -- Just my 0.0002 million dollars worth, Shawn

Re: Regex sending me mad

2012-07-27 Thread Jim Gibson
On Jul 27, 2012, at 7:04 AM, Gary Stainburn wrote: > Hi folks. > > I'm struggling to see what I'm doing wrong. I have the following code in one > of my programs but it isn't working as it should. > > > print STDERR "enqmake='$enqmake' model='$model'\n"; > if (!$enqmake && $model) { # extract