Pattern Search Regular Expression

subhabangalore at gmail.com subhabangalore at gmail.com
Sat Jun 15 13:54:28 EDT 2013


On Saturday, June 15, 2013 3:12:55 PM UTC+5:30, subhaba... at gmail.com wrote:
> Dear Group,
> 
> 
> 
> I am trying to search the following pattern in Python.
> 
> 
> 
> I have following strings:
> 
> 
> 
>  (i)"In the ocean"
> 
>  (ii)"On the ocean"
> 
>  (iii) "By the ocean"
> 
>  (iv) "In this group"
> 
>  (v) "In this group"
> 
>  (vi) "By the new group"
> 
>        .....
> 
> 
> 
> I want to extract from the first word to the last word, 
> 
> where first word and last word are varying.
> 
> 
> 
> I am looking to extract out:
> 
>   (i) the
> 
>   (ii) the 
> 
>   (iii) the
> 
>   (iv) this
> 
>   (v) this
> 
>   (vi) the new
> 
>       .....
> 
> 
> 
> The problem may be handled by converting the string to list and then 
> 
> index of list. 
> 
> 
> 
> But I am thinking if I can use regular expression in Python.
> 
> 
> 
> If any one of the esteemed members can help.
> 
> 
> 
> Thanking you in Advance,
> 
> 
> 
> Regards,
> 
> Subhabrata

Dear Group,

Thank you for the answer. But I want to learn bit of interesting regular expression forms where may I? No Mark, thank you for your links but they were not sufficient. I am looking for more intriguing exercises, esp use of or in the pattern search. 

Regards,
Subhabrata. 



More information about the Python-list mailing list