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

Mailing List Archive: Python: Dev

help required

 

 

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


waqas805 at hotmail

Sep 25, 2009, 11:28 AM

Post #1 of 3 (377 views)
Permalink
help required

Hi,



I dont know it is the right place to post this question. I need help to change one search code line . can you help me please.

here is my search method code:

search=re.compile("^#acl InternationalGroup.*\n", re.M).search(pagetext)
if search:
ret=search.group()



here i am searching for "#acl InternationalGroup" in the pageText and when it true is then give me search group.


I want to change this for following requirement:

I want to search for "#acl InternationalGroup" and "CatInternational" in the pageText.
when "#acl InternationalGroup" is not there but "CatInternational" is there. then return me search group.

I shall be thankful to you for any help.

Best Regards,
Waqas







_________________________________________________________________
Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy!
http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us


fuzzyman at voidspace

Sep 25, 2009, 12:30 PM

Post #2 of 3 (343 views)
Permalink
Re: help required [In reply to]

waqas ahmad wrote:
> Hi,
>
> I dont know it is the right place to post this question. I need help
> to change one search code line . can you help me please.
>

Hello Waqas,

This is a list for the development *of* Python, not for development with
Python. More appropriate lists, where hopefully there will be lots of
people willing to help you, are python-list and python-tutor:

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

Or the google groups gateway for the Python-list (comp.lang.python):

http://groups.google.com/group/comp.lang.python/topics

All the best,

Michael Foord

> here is my search method code:
>
> search=re.compile("^#acl InternationalGroup.*\n", re.M).search(pagetext)
> if search:
> ret=search.group()
>
>
> here i am searching for "#acl InternationalGroup" in the pageText and
> when it true is then give me search group.
>
>
> I want to change this for following requirement:
>
> I want to search for "#acl InternationalGroup" and
> "CatInternational" in the pageText.
> when "#acl InternationalGroup" is not there but "CatInternational" is
> there. then return me search group.
>
> I shall be thankful to you for any help.
>
> Best Regards,
> Waqas
>
>
>
>
>
>
>
> ------------------------------------------------------------------------
> Invite your mail contacts to join your friends list with Windows Live
> Spaces. It's easy! Try it!
> <http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev [at] python
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk
>


--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog


_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


python at mrabarnett

Sep 25, 2009, 12:36 PM

Post #3 of 3 (346 views)
Permalink
Re: help required [In reply to]

waqas ahmad wrote:
> Hi,
>
> I dont know it is the right place to post this question. I need help to
> change one search code line . can you help me please.
>
> here is my search method code:
>
> search=re.compile("^#acl InternationalGroup.*\n", re.M).search(pagetext)
> if search:
> ret=search.group()
>
>
> here i am searching for "#acl InternationalGroup" in the pageText and
> when it true is then give me search group.
>
>
> I want to change this for following requirement:
>
> I want to search for "#acl InternationalGroup" and "CatInternational"
> in the pageText.
> when "#acl InternationalGroup" is not there but "CatInternational" is
> there. then return me search group.
>
> I shall be thankful to you for any help.
>
I'm not clear whether you want the search to succeed if pageText
contains either, or if pageText contains "CatInternational" but not
"#acl InternationalGroup".

Whichever you want, you could use 2 simple separate regular expressions
or 1 more complicated regular expression.

Search for either:

search = re.compile("^#acl InternationalGroup.*\n", re.M).search(pagetext)
if not search:
search = re.compile("^CatInternational.*\n", re.M).search(pagetext)
if search:
ret = search.group()

Search for one but not the other:

search = re.compile("^CatInternational.*\n", re.M).search(pagetext)
if search:
search_2 = re.compile("^#acl InternationalGroup.*\n",
re.M).search(pagetext)
if not search_2:
ret = search.group()

_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com

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


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.