Obtaining matched (sub)string

  • Follow


	When using m//, is it possible to obtain the (sub)string of the
target which actually matched the regex?  For example, if the target is
"Get your viagra here" and the regex is "(cialis|viagra|xanax)", is there
a way to indicate that the match was "viagra"?

Thanks,
Mike
--
             Michael T. Davis              |    Systems Specialist: ChE,MSE
  E-mail: davism@er6.eng.ohio-state.edu    | Departmental Networking/Computing
           -or- DAVISM+@osu.edu            |     The Ohio State University
http://www.er6.eng.ohio-state.edu/~davism/ |     197 Watts, (614) 292-6928
0
Reply DAVISM (21) 5/27/2004 11:25:23 PM

Michael T. Davis wrote:
> When using m//, is it possible to obtain the (sub)string of the 
> target which actually matched the regex?  For example, if the
> target is "Get your viagra here" and the regex is
> "(cialis|viagra|xanax)", is there a way to indicate that the match
> was "viagra"?

Err.. Yes. By examining the content of $1.

     http://www.perldoc.com/perl5.8.4/pod/perlretut.html

(Are there any spam crap any longer that spells out "viagra" in
cleartext?)

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

0
Reply Gunnar 5/27/2004 11:35:47 PM


Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:

> (Are there any spam crap any longer that spells out "viagra" in
> cleartext?)


He may be working on "normalized" words, so his code _may_ be useful.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas
0
Reply Tad 5/28/2004 12:48:17 PM

In article <2hncfsFdhbnmU1@uni-berlin.de>, Gunnar Hjalmarsson
<noreply@gunnar.cc> writes:

>Michael T. Davis wrote:
>> When using m//, is it possible to obtain the (sub)string of the
>> target which actually matched the regex?  For example, if the
>> target is "Get your viagra here" and the regex is
>> "(cialis|viagra|xanax)", is there a way to indicate that the match
>> was "viagra"?
>
>Err.. Yes. By examining the content of $1.
>
>     http://www.perldoc.com/perl5.8.4/pod/perlretut.html

	I must have tried that before when there was another error in
my code.  It's working fine now.

>
>(Are there any spam crap any longer that spells out "viagra" in
>cleartext?)

	Yeah, I still see all sorts of obvious "SPAM words" sent in the
clear.

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

Thanks,
Mike
--
             Michael T. Davis              |    Systems Specialist: ChE,MSE
  E-mail: davism@er6.eng.ohio-state.edu    | Departmental Networking/Computing
           -or- DAVISM+@osu.edu            |     The Ohio State University
http://www.er6.eng.ohio-state.edu/~davism/ |     197 Watts, (614) 292-6928
0
Reply DAVISM 5/28/2004 1:29:40 PM

In article <slrncbed8h.gld.tadmc@magna.augustmail.com>, Tad McClellan
<tadmc@augustmail.com> writes:

>Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
>
>> (Are there any spam crap any longer that spells out "viagra" in
>> cleartext?)
>
>
>He may be working on "normalized" words, so his code _may_ be useful.

	That is, in fact, what I'm doing.  The case I provided was just a
simplification.

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

Regards,
Mike
--
             Michael T. Davis              |    Systems Specialist: ChE,MSE
  E-mail: davism@er6.eng.ohio-state.edu    | Departmental Networking/Computing
           -or- DAVISM+@osu.edu            |     The Ohio State University
http://www.er6.eng.ohio-state.edu/~davism/ |     197 Watts, (614) 292-6928
0
Reply DAVISM 5/29/2004 4:11:54 PM

4 Replies
60 Views

(page loaded in 0.501 seconds)


Reply: