Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Pattern Search Regular Expression

Thread Tools

Pattern Search Regular Expression

Mark Lawrence
Posts: n/a
On 15/06/2013 22:03, Joshua Landau wrote:
> On 15 June 2013 11:18, Mark Lawrence <(E-Mail Removed)> wrote:
>> I tend to reach for string methods rather than an RE so will something like
>> this suit you?
>> c:\Users\Mark\MyPython>type
>> for s in ("In the ocean",
>> "On the ocean",
>> "By the ocean",
>> "In this group",
>> "In this group",
>> "By the new group"):
>> print(' '.join(s.split()[1:-1]))
>> c:\Users\Mark\MyPython>a
>> the
>> the
>> the
>> this
>> this
>> the new

> Careful - " ".join(s.split()) != s
> Eg:
>>>> " ".join("s\ns".split())

> 's s'
> It's pedantry, but true.

I'm sorry but I haven't the faintest idea what you're talking about. I
believe the code I posted works for the OP's needs. If it doesn't
please say so.

"Steve is going for the pink ball - and for those of you who are
watching in black and white, the pink is next to the green." Snooker
commentator 'Whispering' Ted Lowe.

Mark Lawrence

Reply With Quote

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
need regular expression to replace part of result based on a search pattern Jimmy Java 13 07-25-2012 09:37 PM
Search regular expression with search for hex values in files? Peter Hanke Perl Misc 1 01-06-2008 08:54 PM
Regular expression does not work in pattern facet? Johann Sijpkes XML 2 07-14-2004 05:30 PM
Dynamically changing the regular expression of Regular Expression validator VSK ASP .Net 2 08-24-2003 02:47 PM
Serialization of a regular expression pattern MARTIN Herve Java 1 07-22-2003 09:31 PM