Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   RegExp for matching word "karl@aol.com" or word "paul@hotmail.com" ? (http://www.velocityreviews.com/forums/t885002-regexp-for-matching-word-karl-aol-com-or-word-paul-hotmail-com.html)

Gerd Pohlmann 02-04-2004 12:47 PM

RegExp for matching word "karl@aol.com" or word "paul@hotmail.com" ?
 
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 "karl@aol.com" or the full word "paul@hotmail.com" (without quotes)?

(karl@aol.com|paul@hotmail.com)

does not work.

Gerd


Gunnar Hjalmarsson 02-04-2004 01:03 PM

Re: RegExp for matching word "karl@aol.com" or word "paul@hotmail.com"?
 
Gerd Pohlmann wrote:
> 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 "karl@aol.com" or the full word
> "paul@hotmail.com" (without quotes)?
>
> (karl@aol.com|paul@hotmail.com)
>
> 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".

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


Tad McClellan 02-04-2004 01:19 PM

Re: RegExp for matching word "karl@aol.com" or word "paul@hotmail.com" ?
 
Gerd Pohlmann <gpohl@email.com> wrote:


> (karl@aol.com|paul@hotmail.com)
>
> does not work.



Of course not, it is not Perl code.

Did you mean to ask a question about Perl code?

If so, then show us the Perl code that your question is about...


--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas

Robert Meyer 02-04-2004 04:39 PM

Re: RegExp for matching word "karl@aol.com" or word "paul@hotmail.com" ?
 
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 "karl@aol.com" or the full word "paul@hotmail.com" (without quotes)?
>
> (karl@aol.com|paul@hotmail.com)
>
> 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

--
There are only 10 types of people in the world:
Those who understand binary, and those who don't.
http://www.one-m.de
http://www.lugbz.org/documents/smart-questions_de.html


J Krugman 02-04-2004 07:34 PM

Re: RegExp for matching word "karl@aol.com" or word "paul@hotmail.com" ?
 
In <pan.2004.02.04.16.39.16.196934@lnubb.qr> Robert Meyer <rtbvfg99@lnubb.qr> writes:

>(/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/

?



Gunnar Hjalmarsson 02-04-2004 07:46 PM

Re: RegExp for matching word "karl@aol.com" or word "paul@hotmail.com"?
 
J Krugman wrote:
> Robert Meyer writes:
>>
>> (/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/
>
> ?


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.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



All times are GMT. The time now is 04:47 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.