Skip to content

Plain regex string (New class don't escape ) #6

@eromoe

Description

@eromoe

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions