2 Regex Questions

Discussion in 'Python' started by AlphaBravo, Aug 17, 2010.

  1. AlphaBravo

    AlphaBravo Guest

    Hello Comp.Lang,Python,

    1) How do I parse Basic Posix RE's in Python (i need it because of
    some old scripts and a specific OS developed in Seattle)
    2) How can I split a string into sections that MATCH a regex (rather
    then splitting by seperator). Tokenizer-style but ignoring every place
    from where I can't start a match?

    - Thanks, Ariel Ben-Yehuda



    --
    - Ariel Ben-Yehuda
     
    AlphaBravo, Aug 17, 2010
    #1
    1. Advertising

  2. AlphaBravo

    Peter Otten Guest

    AlphaBravo wrote:

    > 2) How can I split a string into sections that MATCH a regex (rather
    > then splitting by seperator). Tokenizer-style but ignoring every place
    > from where I can't start a match?


    >>> import re
    >>> re.compile("[abc]+").findall("abcxaaa! abba")

    ['abc', 'aaa', 'abba']
     
    Peter Otten, Aug 17, 2010
    #2
    1. Advertising

  3. AlphaBravo

    AlphaBravo Guest

    On Aug 17, 10:23 am, Peter Otten <> wrote:
    > AlphaBravo wrote:
    > >  2) How can I split a string into sections that MATCH a regex (rather
    > > then splitting by seperator). Tokenizer-style but ignoring every place
    > > from where I can't start a match?
    > >>> import re
    > >>> re.compile("[abc]+").findall("abcxaaa! abba")

    >
    > ['abc', 'aaa', 'abba']


    Thanks for 2
     
    AlphaBravo, Aug 17, 2010
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SmViQnVzaGVsbA==?=

    Is ASP Validator Regex Engine Same As VS2003 Find Regex Engine?

    =?Utf-8?B?SmViQnVzaGVsbA==?=, Oct 22, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    724
    =?Utf-8?B?SmViQnVzaGVsbA==?=
    Oct 22, 2005
  2. Rick Venter

    perl regex to java regex

    Rick Venter, Oct 29, 2003, in forum: Java
    Replies:
    5
    Views:
    1,650
    Ant...
    Nov 6, 2003
  3. Replies:
    2
    Views:
    614
  4. Xah Lee
    Replies:
    1
    Views:
    954
    Ilias Lazaridis
    Sep 22, 2006
  5. Replies:
    3
    Views:
    794
    Reedick, Andrew
    Jul 1, 2008
Loading...

Share This Page