I want to exclude an expression of a sequence of charecters with regex

Discussion in 'Python' started by 28tommy, Dec 27, 2005.

  1. 28tommy

    28tommy Guest

    Hello all,

    I know how to exclude 1 charecter from a compiled sequence of the re
    module- '[^a]', but if I want to exclude a word or a sequence as one
    unit (not as separate charecters) to be checked.... how do I do that?

    I tried re.compile('[^(abc)]')
    .... or re.compile('[^a][^b][^c]')
    .... or re.compile('[^a^b^c]')
    None of these worked.

    Thanks in advance (-:
    28tommy, Dec 27, 2005
    #1
    1. Advertising

  2. Re: I want to exclude an expression of a sequence of charecters withregex

    "28tommy" wrote:

    > I know how to exclude 1 charecter from a compiled sequence of the re
    > module- '[^a]', but if I want to exclude a word or a sequence as one
    > unit (not as separate charecters) to be checked.... how do I do that?
    >
    > I tried re.compile('[^(abc)]')
    > ... or re.compile('[^a][^b][^c]')
    > ... or re.compile('[^a^b^c]')
    > None of these worked.


    look for "negative lookahead assertion" on this page:

    http://docs.python.org/lib/re-syntax.html

    </F>
    Fredrik Lundh, Dec 27, 2005
    #2
    1. Advertising

  3. 28tommy

    28tommy Guest

    Thanks.
    28tommy, Dec 28, 2005
    #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. Alex Smith
    Replies:
    1
    Views:
    303
    Kevin Spencer
    Jun 17, 2005
  2. Bruce Sam
    Replies:
    1
    Views:
    351
    =?UTF-8?b?TMSByrtpZSBUZWNoaWU=?=
    Dec 17, 2004
  3. jeff
    Replies:
    2
    Views:
    277
    Paul Watson
    Jan 23, 2004
  4. Vishal Dalsania

    Garbage Charecters

    Vishal Dalsania, Jul 27, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    357
    Vishal Dalsania
    Jul 27, 2006
  5. Index

    remove junk charecters

    Index, Oct 6, 2006, in forum: C++
    Replies:
    4
    Views:
    389
    Index
    Oct 6, 2006
Loading...

Share This Page