Giter Site home page Giter Site logo

Comments (4)

erzvtvhfm-fhjnyfxv avatar erzvtvhfm-fhjnyfxv commented on July 18, 2024

Issue still exists 😞 Used version is exrex-0.10.5.

$ exrex -s '\..'
..

from exrex.

vwyu avatar vwyu commented on July 18, 2024

It seems that the issue is due to the following lines of sre_to_string method in exrex.py:

elif i[0] == sre_parse.LITERAL:
    ret += unichr(i[1])

The issue appears to be resolved, if we change these lines as follows:

elif i[0] == sre_parse.LITERAL:
    u = unichr(i[1])
    ret += u if u not in sre_parse.SPECIAL_CHARS else '\\{0}'.format(u)

After the change, I get:

>>> import exrex
>>> exrex.simplify(r'\.')
'\\.'
>>> exrex.simplify('[.]')
'\\.'
>>> exrex.simplify('.')
'.'
>>> exrex.simplify(r'\$')
'\\$'
>>> exrex.simplify('[$]')
'\\$'
>>> exrex.simplify('[a]')
'a'

I belive that exrex.simplify('[.]') returning '\\.' and exrex.simplify('[$]') returning '\\$' are correct behaviors, since both cases involve special characters in ranges [].

from exrex.

iamthad avatar iamthad commented on July 18, 2024

@vwyu That does indeed appear to fix the issue. Do you want to make a pull request?

from exrex.

scopatz avatar scopatz commented on July 18, 2024

I am also seeing this on 0.10.5 with [*]

from exrex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.