Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

Clarify Regex in Python.

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


cooldudevamsee at gmail

Sep 12, 2006, 5:07 AM

Post #1 of 8 (246 views)
Permalink
Clarify Regex in Python.

After may frustrated attempts I came to know that "match" function in
python re package actually start the matchs at the begining of the
subject, where "search" will find the given pattern any where in the
subject.

My Problem is, I want to know how can I force match functions to match
the pattern any location in the subject. i.e I want to turn off before
said behaviour.


Thanks In advance.

--
http://mail.python.org/mailman/listinfo/python-list


amk at amk

Sep 12, 2006, 5:15 AM

Post #2 of 8 (224 views)
Permalink
Re: Clarify Regex in Python. [In reply to]

On 12 Sep 2006 05:07:03 -0700,
cooldudevamsee[at]gmail.com <cooldudevamsee[at]gmail.com> wrote:
> My Problem is, I want to know how can I force match functions to match
> the pattern any location in the subject. i.e I want to turn off before
> said behaviour.

Use search() instead; that's why the method is there.

(Or put .* at the beginning of all your patterns, though that will be
slightly slower.)

--amk
--
http://mail.python.org/mailman/listinfo/python-list


steve at holdenweb

Sep 12, 2006, 5:22 AM

Post #3 of 8 (225 views)
Permalink
Re: Clarify Regex in Python. [In reply to]

cooldudevamsee[at]gmail.com wrote:
> After may frustrated attempts I came to know that "match" function in
> python re package actually start the matchs at the begining of the
> subject, where "search" will find the given pattern any where in the
> subject.
>
> My Problem is, I want to know how can I force match functions to match
> the pattern any location in the subject. i.e I want to turn off before
> said behaviour.
>
>
> Thanks In advance.
>
Erm, is there some specific reason why you can't just use the search
method? Why does it *have* to be match()?

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

--
http://mail.python.org/mailman/listinfo/python-list


cooldudevamsee at gmail

Sep 12, 2006, 5:37 AM

Post #4 of 8 (224 views)
Permalink
Re: Clarify Regex in Python. [In reply to]

> Erm, is there some specific reason why you can't just use the search
> method? Why does it *have* to be match()?
>
> regards
> Steve


I know there r many more methods to do the job, I just wonder can we
turnoff the default behaviour of match method.

Thanks.

--
http://mail.python.org/mailman/listinfo/python-list


sjmachin at lexicon

Sep 12, 2006, 5:46 AM

Post #5 of 8 (224 views)
Permalink
Re: Clarify Regex in Python. [In reply to]

cooldudevamsee[at]gmail.com wrote:
> > Erm, is there some specific reason why you can't just use the search
> > method? Why does it *have* to be match()?
> >
> > regards
> > Steve
>
>
> I know there r many more methods to do the job, I just wonder can we
> turnoff the default behaviour of match method.
>

Don't wonder. Read the documentation. There is a whole section devoted
to match versus search. If you believe there are undocumented keyword
arguments to the match method and we are wantonly withholding the
information, then you should check out your theory by downloading the
source code and reading that.

HTH,
John

--
http://mail.python.org/mailman/listinfo/python-list


fredrik at pythonware

Sep 12, 2006, 5:59 AM

Post #6 of 8 (234 views)
Permalink
Re: Clarify Regex in Python. [In reply to]

cooldudevamsee[at]gmail.com wrote:

> I know there r many more methods to do the job, I just wonder can we
> turnoff the default behaviour of match method.

that's not the "default behaviour", that's how match works. if you want
search, use search instead.

</F>

--
http://mail.python.org/mailman/listinfo/python-list


cooldudevamsee at gmail

Sep 12, 2006, 8:18 AM

Post #7 of 8 (225 views)
Permalink
Re: Clarify Regex in Python. [In reply to]

k, people, thanks for ur replys.

--
http://mail.python.org/mailman/listinfo/python-list


hancock at anansispaceworks

Sep 12, 2006, 1:34 PM

Post #8 of 8 (224 views)
Permalink
Re: Clarify Regex in Python. [In reply to]

cooldudevamsee[at]gmail.com wrote:

> After may frustrated attempts I came to know that "match" function
> in python re package actually start the matchs at the begining of the
> subject, where "search" will find the given pattern any where in the
> subject.
>
> My Problem is, I want to know how can I force match functions to
> match the pattern any location in the subject. i.e I want to turn off
> before said behaviour.

re.match = re.search

perhaps?

Stupid thing to do, but it meets the spec.

Cheers,
Terry


--
Terry Hancock (hancock[at]AnansiSpaceworks.com)
Anansi Spaceworks http://www.AnansiSpaceworks.com

--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.