RE: Reg. expression help

2005-02-16 Thread Erich Beyrent
> Hi, > Can someone help me with the syntax of deleting the last word of text string. > i.e. $string = 'my abc 123' > Like to have only 'my abc' > > Thanks, > David #!/usr/bin/perl $string = 'some string'; $string =~ s/(?<=\s)(.*?)$//g; print "String = $string\n"; HTH -Erich- _

RE: Reg. expression help

2005-02-16 Thread Tom Pollard
On Wed, 16 Feb 2005, Erich Beyrent wrote: > > Can someone help me with the syntax of deleting the last word of text > string. > > i.e. $string = 'my abc 123' > > Like to have only 'my abc' > > #!/usr/bin/perl > > $string = 'some string'; > $string =~ s/(?<=\s)(.*?)$//g; > > print "String = $st

RE: Reg. expression help

2005-02-16 Thread Peter Eisengrein
You can do this a few ways. Here are two: my ($way_1) = $string =~ /(\w+\s{1,}\w+)\s{1,}\w+$/; my ($way_2) = join(" ",@_[0,1] = split(/ +/,$string)); print "way_1 = $way_1\n"; print "way_2 = $way_2\n"; Out of curiosity, I benchmarked these and the regex is faster than the array slice. Lucky for

Re: Reg. expression help

2005-02-16 Thread Ing. Branislav Gerzo (mail-lists)
Hsu, David [HD], on Wednesday, February 16, 2005 at 10:26 (-0500) thoughtfully wrote the following: HD> Can someone help me with the syntax of deleting the last word of text HD> string. HD> i.e. $string = 'my abc 123' HD> Like to have only 'my abc' my $string = 'my abc 123 f '; $string =~ s/(.*)\

Re: Reg. expression help

2005-02-16 Thread Сергей Черниенко
Hello David, Wednesday, February 16, 2005, 5:26:22 PM, Вы написали: HD> Hi, HD> Can someone help me with the syntax of deleting the last word of text HD> string. HD> i.e. $string = 'my abc 123' HD> Like to have only 'my abc' use strict; my $string = 'my abc 123'; $_ = $string; my @string = spl

RE: Reg. expression help

2005-02-16 Thread Gerber, Christopher J
-Original Message- > Can someone help me with the syntax of deleting the last word of text string. > i.e. $string = 'my abc 123' > Like to have only 'my abc' David, Quick and easy: $string = 'my abc 123'; $string =~ s/\s+\S+$//; This assumes that you are replacing one or more whitespac

RE: Reg Expression Help

2006-03-23 Thread Dirk Bremer
Try '^[\[\]a-zA-Z0-9-_. ]+$' Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St. Louis MO - USA Central Time Zone 636-755-2652 fax 636-755-2503 [EMAIL PROTECTED] www.nisc.coop From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf

RE: Reg Expression Help

2006-03-23 Thread Bullock, Howard A.
Scott wrote: How can I incorporate the possibility of having a [ or ] in the user input? /^[a-zA-Z0-9-_. \[\]]+$/ ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysub

RE: Reg Expression Help

2006-03-23 Thread Wagner, David --- Senior Programmer Analyst --- WGO
  -Original Message-From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Scott PurcellSent: Thursday, March 23, 2006 12:05To: Perl-Win32-Users@listserv.ActiveState.comSubject: Reg _expression_ Help Hello,   I have a regular _expression_ in which I a

RE: Reg Expression Help

2006-03-23 Thread Joe Discenza
Scott Purcell wrote, on Thursday, March 23, 2006 3:05 PM   : '^[a-zA-Z0-9-_. ]+$'   The others helped you get [] in there. But hyphen (dash) has to be first, or it looks like a range operator. So try:   ^[-a-zA-Z0-9_. \[\]]+$   Good luck,   Joe   ___

RE: Reg Expression Help

2006-03-23 Thread lim Ee Wah
Hi, I think you should escape that period and dash as well.'^[a-zA-Z0-9-_. \[\]]+$''^[a-zA-Z0-9\-_\. \[\]]+$'or may be simpler:'^[\w\d_\-\. \[\]]+$' ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://list