RegExp for matching word "[email protected]" or word "[email protected]" ?

G

Gerd Pohlmann

Just a stupid question from a newbie:
How do I setup a reg exp which matches if the text (line) contains
either the full word "(e-mail address removed)" or the full word "(e-mail address removed)" (without quotes)?

([email protected]|[email protected])

does not work.

Gerd
 
G

Gunnar Hjalmarsson

Gerd said:
Just a stupid question from a newbie:
How do I setup a reg exp which matches if the text (line) contains
either the full word "(e-mail address removed)" or the full word
"(e-mail address removed)" (without quotes)?

([email protected]|[email protected])

does not work.

Does not work?

Please post a small but complete program, where you have included "use
strict;" and "use warnings;" at the top, and that illustrates your
problem. Let us know which error or warning messages you get (if any),
and try to avoid just saying "does not work".
 
R

Robert Meyer

Am Wed, 04 Feb 2004 13:47:49 +0100 schrieb Gerd Pohlmann:
Just a stupid question from a newbie:
How do I setup a reg exp which matches if the text (line) contains
either the full word "(e-mail address removed)" or the full word "(e-mail address removed)" (without quotes)?

([email protected]|[email protected])

does not work.

Gerd

Hi Gerd,

you have to mask the @ and the . with a \

So it looks like this
(karl\@aol\.com|paul\@hotmail\.com)

If you want to use it in a Perl Program then you must includ it into two /
like this
(/karl\@aol\.com/|/paul\@hotmail\.com/)

If you want to learn more about Regexp then use ISBN 3-89721-349-4 from
O'Reilly.

greets
Robert
 
J

J Krugman

In said:
(/karl\@aol\.com/|/paul\@hotmail\.com/)

That looks like a bitwise OR of two scalars... I suppose it would
work, but it's not terribly good Perl. How about

/karl\@aol\.com|paul\@hotmail\.com/

?
 
G

Gunnar Hjalmarsson

J said:
That looks like a bitwise OR of two scalars... I suppose it would
work, but it's not terribly good Perl. How about

/karl\@aol\.com|paul\@hotmail\.com/

?

Yeah, but since the email addresses are plain strings, it would
probably be even better Perl to make use of the index() function
instead of a regular expression.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top