[ic] perl issue
Christian Brink
cbrink at brinkrods.com
Sat Jul 17 19:42:23 EDT 2004
> Aha thanks I did get that to work. But I guess I phrased my question
> poorly... I want to keep what remains and discard the $prefix. In other
> words I want to remove the first hyphen and all the comes before it
> leaving everything else. I can probably cobble together something based
> on your post but of course I welcome any input.
No problem, that's much easier.
my $string = 'ABC-DEF-GH-IJK';
$string =~ s/^[^-]+-(.*)/$1/;
Explaination:
'=~' - do a regex
's/' - It's a substitution
'^' the first one - Means regex must start at the beginning
'[^-]' - Negated character class - Mean any character that is not '-'
'+' - Grab at least one, but can grab as many as you find
'-' - just the dash character
'(.*)' - '()' mean save everything inside '.*' means grab any character you
find.
'/$1/' - $1 is what was saved in the '()'s and replaces the sting with that
HTH,
Christian Brink - Fly Rod Maker
http://www.brinkrods.com
cbrink at brinkrods.com
Authorized Gatti Dealer
More information about the interchange-users
mailing list