RE: simple regex question

2004-10-15 Thread Gerber, Christopher J
> "bruce" <[EMAIL PROTECTED]> > > $foo = "foo.txt" > > > > i simply want to separate on the "." > > Try: > > use File::Basename; > # > my $foo = "foo.txt"; > my $ans = fileparse($foo, ('.txt')); > print "$ans\n"; > If you REALLY want to use the regex, you could try one of the following: --

Re: simple regex question

2004-10-15 Thread Martin Leese
"bruce" <[EMAIL PROTECTED]> hi.. a simple/basic/embarassingly simple one... i have: $foo = "foo.txt" i simply want to separate on the "." ie $foo =~ /([^.]+).txt/ $ans = $1 this doesn't seem to get $ans = 'foo' Try: use File::Basename; # my $foo = "foo.txt"; my $ans = fileparse($foo, ('.txt'));

RE: simple regex question

2004-10-15 Thread Andy_Bach
A further debug/syntax nitpick: print "foo='$foo'\n"; $foo =~ /([^.]+).txt/; $ans = $1; print "ans='$ans'\n"; best as: my ($foo, $ans); print "foo='$foo'\n"; if ( $foo =~ /([^.]+)\.txt/ ) { $ans = $1; } else { $ans="match failed on: $foo"; } print "ans='$ans'\n"; if you ch

RE: simple regex question

2004-10-15 Thread bruce
'ppreciate the responses!! it was a typo! f^*&ng fingers!! -bruce -Original Message- From: Gardner, Sam [mailto:[EMAIL PROTECTED] Sent: Friday, October 15, 2004 10:54 AM To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED] Subject: RE: simple regex question Well, just as a

RE: simple regex question

2004-10-15 Thread Joseph Discenza
bruce wrote, on Friday, October 15, 2004 1:39 PM : a simple/basic/embarassingly simple one... : : i have: : : $foo = "foo.txt" : : i simply want to separate on the "." : : ie : $foo =~ /([^.]+).txt/ : $ans = $1 : : this doesn't seem to get $ans = 'foo' Maybe you're going for s

Re: simple regex question

2004-10-15 Thread O'K Web Design
Hi Bruce I would use split(/\./,$foo) Mike - Original Message - From: "bruce" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: October 15, 2004 1:38 PM Subject: simple regex question > hi.. > > a simple/basic/embarassingly simple one... > > i have: > > $foo = "foo.txt" > >

RE: simple regex question

2004-10-15 Thread Gardner, Sam
Title: RE: simple regex question Well, just as a basic note, you are aware that the "." in regexes matches ANY character (except a newline, in most situations), right?  But also, you seem to have put ^. Inside a character class, so it won't be "beginning of the string, an

Re: simple regex question

2004-10-15 Thread Kester Allen
Hi Bruce-- You're getting confused by the multiple regexp uses of ".". When it is in a character class or escaped: "[.]" or "\.", it means a literal period, when it's unescaped: "." it means "any character." You've got them backwards in your regexp. Try: perl -le '$foo = qq/foo.txt/; $foo =~ /

RE: simple regex question

2004-10-15 Thread Arms, Mike
Works for me. Might I suggest adding simple debugging print statements before and after your match: print "foo='$foo'\n"; $foo =~ /([^.]+).txt/; $ans = $1; print "ans='$ans'\n"; Maybe $foo doesn't contain what you think it does. Also, a nitpick, but you did not include the semicolons whi