Git Product home page Git Product logo

crocs's People

Contributors

iogf avatar mixmastamyk avatar prikers avatar wbolster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

crocs's Issues

Plain regex string (New class don't escape )

I think this project is good for group many pattern together, for beginers .

  1. Usually we already have some regex pattern, don't want to rewrite them
  2. Usually we need some build-in pattern, such as \d , \s , \S , ? . It is no need to write all easy pattern in crocs way, just plain regex string is easy understand.

Now, crocs would escape all

crocs/crocs.py

Line 29 in a7098ae

return re.escape(self.value)

For example:

x = X()

no_lf = P(E('\n'))
to_lf = T(no_lf, 1)
xplus = T(no_lf, 1)
xstar = T(no_lf, 0)

p1_ng = NG('project', to_lf)
p2_ng = NG('project', xplus)

project = Any(
    P('(名称|编号)\s{0,5}(:|为)', p1_ng),    #  1
    P('test', p2,'test'),                               #  2
    P('test《?', p2,'》?test'),                    #  3
)

re.findall(project.to_regex,  xxx)

Here, 1 and 3 would not work.

using the generated regex in the re module

Hi,

love the work you've done here.
I've tried to play with it a little bit, creating the regex and passing it to the re module.

The only way I've found to do it is to use the seed function like this:

from crocs import *
import re
g = Group('X',Times(Include(Seq('0', '9')), 1, 2))
e = Pattern(g, Times(Include(Seq('a', 'z')), 1, 3), g)
regex_str = e.seed()[0]
re.findall(regex_str, "X6zX6")

it this the official way to do it? I couldn't find any indication in the wiki about this. Wouldn't a property be more appropriate to access it, something like e.regex or similar?

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.