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

Can I use regex such as \K , \R, \G or (*SKIP)(*FAIL) (*PRUNE)…? #503

Open
me-suzy opened this issue Jul 1, 2023 · 3 comments
Open

Can I use regex such as \K , \R, \G or (*SKIP)(*FAIL) (*PRUNE)…? #503

me-suzy opened this issue Jul 1, 2023 · 3 comments

Comments

@me-suzy
Copy link

me-suzy commented Jul 1, 2023

I want to use this kind of regex formula în Python. How can I do that ? Python (import te) is very, very limited.

(?:<p class="mb-40px">|\G).*?\K(?:<a href=.+?</a>(*SKIP)(*FAIL)|<(?:(?!/?p).)+?>)

Backtracking Control Verbs Tutorial https://www.rexegg.com/backtracking-control-verbs.html

I use all the time regex formula în Perl ore Notepad++, but Python (import te) don’t know the operators such as \K , \R, \G or (*SKIP)(*FAIL) (*PRUNE)…and much more.

these are very important in solving problems and are absolutely necessary because they simplify things a lot.

Can You Tell me how can I use them în Python, for search and replace? Can You show an example ?

@mrabarnett
Copy link
Owner

The regex module supports all but \R. In Python you usually open files with "universal line endings" (the default) which converts \r\n, \r and \n to \n, so there's not much need for \R.

The module is written to be compatible with Python's re module, so you can use it in the same way, but with extra features.

@me-suzy
Copy link
Author

me-suzy commented Jul 1, 2023

What extra features?

More important, can I use:

\K , \G or (*SKIP)(*FAIL) (*PRUNE)…and much more?

@makyen
Copy link

makyen commented Jul 1, 2023

@me-suzy There's documentation for this project, which is displayed both on PyPi and the front page of this repository. It really seems like you haven't even tried to read it or search through it. The specific questions you're asking can be determined with quick Ctrl-F searches through that documentation, and that should be your first method of trying to gain that information. If you can't find it that way, then ask.

If you're having problems, people are generally quite willing to help, but asking people to, effectively, copy and paste what's already in the documentation isn't reasonable. This project, and other projects spend considerable time on creating documentation, so that people can have ready access to that type of information. Asking them to re-expend that time doesn't feel good from the point of view of the person being asked. On the other hand, if there's something in the documentation that isn't clear when you read it, then the people who wrote it usually want to know, so they can clarify it for you, and update the documentation for everyone else.

It's also really not reasonable to ask such a general question as "What extra features?" when describing that is exactly what the documentation is for. The other side of that is that it is beneficial to let the maintainers know that it would help other people make decisions about using the project to have a section at the beginning of the documentation which has a bullet-item list of the new and changed features relative to the baseline re library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants