Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 21st, 2004, 08:21 AM
Omega81 Omega81 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 15 Omega81 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 m 55 sec
Reputation Power: 0
Send a message via ICQ to Omega81 Send a message via Yahoo to Omega81
Question regular expression

I was wondering if anyone knows a goods tutorial on using regular expressions. I have gone through the phython manual and tutorial in the supplied documentation but it is not detailed. Also how would I get everthig after the "hello" in this string using the regular expersion module?

" What a nice day guys. hello it's me Omega "

thank you

Reply With Quote
  #2  
Old May 21st, 2004, 09:20 AM
DevCoach DevCoach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2004
Location: London, England
Posts: 1,226 DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 23 h 35 m 17 sec
Reputation Power: 263
There is a tutorial at http://www.amk.ca/python/howto/regex/.

The book 'Text Processing in Python' by David Mertz has a chapter on regular expressions. You can find a web copy of the book at http://gnosis.cx/TPiP/.

In answer to your second question:

Code:
>>> import re
>>> s = " What a nice day guys. hello it's me Omega "
>>> match = re.search(r'hello(.*)', s)
>>> match.group(1)
" it's me Omega "


The regular expression "hello(.*)" will match the "hello", then assign all the text after it to a group, which can then be extracted from the match object.

Dave - The Developers' Coach

Last edited by DevCoach : May 21st, 2004 at 09:23 AM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > regular expression


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT