From: Paul Mooring <[email protected]>
> This is probably a really obvious question but how can I match
> everything up to a character not including that character with regex?
> For example:
> [email protected] => person
> [email protected] => me

#!/usr/bin/perl -w
$a="[email protected]";
$a=~m/^(.*)\@/;
$b=$1;
print "a= $a\n";
print "b= $b\n";

You may have to modify the regex and the structures for non-Perl
languages since @ is a special char in Perl and may not be in others.
The regex here matches everything from the beginning of the string
up to the first @, not including the @, and puts it in $1 or \1
(first backreference).

But if this was all I wanted, I might use a substr instead of a
regex, since regexes are a bit more complex than what you said
you wanted.  (Don't use a .50 to shoot a chipmunk, etcetera....)

-- 
Matt G / Dances With Crows
The Crow202 Blog:  http://crow202.org/wordpress/
There is no Darkness in Eternity/But only Light too dim for us to see


---------------------------------------------------
PLUG-discuss mailing list - [email protected]
To subscribe, unsubscribe, or to change your mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss

Reply via email to