Skip to content

Regex 0.1.20101210 #54912

Closed
Closed

Description

@stiv
mannequin
BPO 10703
Nosy @abalkin
Superseder
  • bpo-2636: Adding a new regex module (compatible with re)
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2010-12-14.18:09:57.896>
    created_at = <Date 2010-12-14.17:41:57.168>
    labels = ['expert-regex', 'type-bug', 'invalid']
    title = 'Regex 0.1.20101210'
    updated_at = <Date 2010-12-15.10:30:14.067>
    user = 'https://bugs.python.org/stiv'

    bugs.python.org fields:

    activity = <Date 2010-12-15.10:30:14.067>
    actor = 'stiv'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-12-14.18:09:57.896>
    closer = 'belopolsky'
    components = ['Regular Expressions']
    creation = <Date 2010-12-14.17:41:57.168>
    creator = 'stiv'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 10703
    keywords = []
    message_count = 4.0
    messages = ['123961', '123965', '123977', '124013']
    nosy_count = 3.0
    nosy_names = ['belopolsky', 'mrabarnett', 'stiv']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = None
    status = 'closed'
    superseder = '2636'
    type = 'behavior'
    url = 'https://bugs.python.org/issue10703'
    versions = ['Python 2.7']

    Activity

    1. stiv commented on Dec 14, 2010

      stivmannequin
      MannequinAuthor

      The regex package doesn't seem to correctly implement the single grapheme match "\X" (\P{M}\p{M}*) for pre-Python 3. I'm using the string "íi-te" (i, U+0301, i, -, t, e -- where U+0301 is Unicode COMBINING ACUTE ACCENT), reading it in from a file to bypass Unicode c&p issues in the older IDLEs).

      stiv@x$ python3.1
      Python 3.1.2 (r312:79147, May 19 2010, 11:50:28) 
      [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
      Type "help", "copyright", "credits" or "license" for more information.
      >>> import regex
      >>> file = open("test_data", "rt", encoding="utf-8")
      >>> s = file.readline()
      >>> print (s)
      íi-te
      >>> print (g.findall(s))
      ['í', 'i', '-', 't', 'e']
      • Correct in 3.1 - i+U+0301 considered one grapheme.
      stiv@x$ python2.7
      Python 2.7 (r27:82500, Oct  4 2010, 14:49:53) 
      [GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
      Type "help", "copyright", "credits" or "license" for more information.
      >>> import codecs                                
      >>> import regex
      >>> file = codecs.open("test_data", "r", "utf-8")
      >>> g = regex.compile("\X")
      >>> s = file.readline()
      >>> s
      u'i\u0301i-te'
      >>> print s.encode("utf-8")
      íi-te
      >>> print g.findall(s)
      [u'i', u'\u0301', u'i', u'-', u't', u'e']

      *Not correct -- accent is treated as a separate character.

      Thanks.

    2. abalkin commented on Dec 14, 2010

      @abalkin
      Member

      Regex 0.1.20101210 is not part of the standard Python distribution, so this bug report is invalid.

    3. mrabarnett commented on Dec 14, 2010

      mrabarnettmannequin
      Mannequin

      The regex module is intended to replace the re module, so its default behaviour is the same: in Python 2, regexes default to matching ASCII, and in Python 3, they default to matching Unicode.

      If you want to use a regex on a Unicode string in Python 2 then you need to set the Unicode flag, either by providing the UNICODE flag or by putting "(?u)" in the regex itself.

    4. stiv commented on Dec 15, 2010

      stivmannequin
      MannequinAuthor

      (Forehead slap.)

      On Tue, 14 Dec 2010, Matthew Barnett wrote:

      Matthew Barnett <python@mrabarnett.plus.com> added the comment:

      The regex module is intended to replace the re module, so its default behaviour is the same: in Python 2, regexes default to matching ASCII, and in Python 3, they default to matching Unicode.

      If you want to use a regex on a Unicode string in Python 2 then you need to set the Unicode flag, either by providing the UNICODE flag or by putting "(?u)" in the regex itself.

      ----------


      Python tracker <report@bugs.python.org>
      <http://bugs.python.org/issue10703\>


    5. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions