Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standard regular expression #1

Closed
IlyaEp opened this issue Sep 23, 2020 · 1 comment
Closed

Standard regular expression #1

IlyaEp opened this issue Sep 23, 2020 · 1 comment
Labels
question Further information is requested

Comments

@IlyaEp
Copy link
Contributor

IlyaEp commented Sep 23, 2020

Hello,

I would like to use standard regular expressions along with the core functions of your library, such as building an automaton from a regular expression. How can i do this?

Thanks for pyformlang!

@Aunsiels
Copy link
Owner

Aunsiels commented Sep 23, 2020

Hi,

I am happy you like and use Pyformlang!

I wrote the wrapper PythonRegex: https://github.com/Aunsiels/pyformlang/blob/master/pyformlang/regular_expression/python_regex.py#L43. However, it does not contain all operations. You can access to:

  • Set of characters with [] (no inverse with [^...])
  • positive closure +
  • . for all printable characters
  • ? for optional character/group
  • Shortcuts: \d, \s, \w

For example:

PythonRegex("a[a-z]")
PythonRegex(r"a[\da]")

You can also give a regular expression directly to PythonRegex.

PythonRegex(re.compile("[a-e-g-z]*"))

You can check the tests for more examples: https://github.com/Aunsiels/pyformlang/blob/master/pyformlang/regular_expression/tests/test_python_regex.py

If you require additional operations, please let me know so I can consider adding them.

@Aunsiels Aunsiels closed this as completed Oct 6, 2020
@Aunsiels Aunsiels added the question Further information is requested label Oct 9, 2020
Aunsiels pushed a commit that referenced this issue Jul 15, 2021
Aunsiels pushed a commit that referenced this issue Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants