Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #48371

Re: Pattern Search Regular Expression

From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: Pattern Search Regular Expression
Date 2013-06-15 22:26 +0100
References <afd6b280-3b64-467b-a2e1-2b36377cd13a@googlegroups.com> <kphf0l$qla$1@ger.gmane.org> <CAN1F8qVKaRBCD11qgbruJeMQrQG4ZRrXShApckQ7i5dLiGRR4g@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.3411.1371331591.3114.python-list@python.org> (permalink)

Show all headers | View raw


On 15/06/2013 22:03, Joshua Landau wrote:
> On 15 June 2013 11:18, Mark Lawrence <breamoreboy@yahoo.co.uk> wrote:
>> I tend to reach for string methods rather than an RE so will something like
>> this suit you?
>>
>> c:\Users\Mark\MyPython>type a.py
>> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Pattern Search Regular Expression subhabangalore@gmail.com - 2013-06-15 02:42 -0700
  Re: Pattern Search Regular Expression Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-15 10:05 +0000
    Re: Pattern Search Regular Expression Denis McMahon <denismfmcmahon@gmail.com> - 2013-06-15 10:24 +0000
      Re: Pattern Search Regular Expression Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-06-15 11:55 +0100
        Re: Pattern Search Regular Expression rusi <rustompmody@gmail.com> - 2013-06-15 04:28 -0700
        Re: Pattern Search Regular Expression Denis McMahon <denismfmcmahon@gmail.com> - 2013-06-15 13:41 +0000
          Re: Pattern Search Regular Expression Denis McMahon <denismfmcmahon@gmail.com> - 2013-06-15 13:45 +0000
            Re: Pattern Search Regular Expression Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-06-15 15:28 +0100
              Re: Pattern Search Regular Expression subhabangalore@gmail.com - 2013-06-15 07:31 -0700
                Re: Pattern Search Regular Expression Andreas Perstinger <andipersti@gmail.com> - 2013-06-15 17:01 +0200
                Re: Pattern Search Regular Expression Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-06-15 16:04 +0100
                Re: Pattern Search Regular Expression subhabangalore@gmail.com - 2013-06-15 09:28 -0700
                Re: Pattern Search Regular Expression Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-06-15 17:39 +0100
                Re: Pattern Search Regular Expression Terry Reedy <tjreedy@udel.edu> - 2013-06-15 16:24 -0400
  Re: Pattern Search Regular Expression Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-06-15 11:18 +0100
  Re: Pattern Search Regular Expression rurpy@yahoo.com - 2013-06-15 09:59 -0700
  Re: Pattern Search Regular Expression subhabangalore@gmail.com - 2013-06-15 10:54 -0700
    Re: Pattern Search Regular Expression rurpy@yahoo.com - 2013-06-15 11:47 -0700
      Re: Pattern Search Regular Expression subhabangalore@gmail.com - 2013-06-15 12:38 -0700
      Re: Pattern Search Regular Expression rurpy@yahoo.com - 2013-06-15 13:41 -0700
  Re: Pattern Search Regular Expression Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-15 22:03 +0100
  Re: Pattern Search Regular Expression Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-06-15 22:26 +0100

csiph-web