Comments (11)
Original comment by Anonymous.
or even something like this would be more powerful:
'@(hotmail\.com){0<e<3}'
matching only texts with 1 or 2 errors
from mrab-regex.
Original comment by Anonymous.
A regex such as:
@(hotmail\.com){e=1}
can be we written as:
@(?>(hotmail\.com){e<=1})(?<!@hotmail\.com)
although that's not quite as convenient, I admit! :-)
Note that the fuzzy part needs to be in an atomic group in order to stop it backtracking to find a worse match. For example, given the string "@hotmail.comb", the fuzzy part will match "@hotmail.com" with 0 errors, then the negative look-behind will reject it, so the fuzzy part will match "@hotmail.comb" with 1 error.
I'm not sure how easy it'll be to add a lower limit; such a problem could still occur.
from mrab-regex.
Original comment by Anonymous.
I think I've figured out how to do it, but how much demand is for it? You gave an example, but is that a real use case?
from mrab-regex.
Original comment by Anonymous.
I am fixing tags for 25k+ text documents for a web site, so I do have a real (different) use case. That was just an example. But I think it would be a really nice feature for regex module...
from mrab-regex.
Original comment by Anonymous.
Could you provide a few test cases?
from mrab-regex.
Original comment by Anonymous.
here is a real example translated into english
3 servic detection
1 service detect
5 service detecti
46 service detection
1 in service detection
The site has manually entered tags, and their frequencies from 25k+ (non-english) text documents. Most of the time the correct one has a high frequency, and anything that is close enough to a correct one (except itself) should probably get fixed..
from mrab-regex.
Original comment by Anonymous.
What fuzzy regex would you use to match the incorrect strings in your example? Would it be this:
(?:^\d+ service detection$){1<=e<=3}
from mrab-regex.
Original comment by Anonymous.
no no, the first part is the frequency of a tag, not part of it. I would search a match with:
r = compile(r'(?:service detection){0<e<5}')
m = r.match(str)
if m:
from mrab-regex.
Original comment by Anonymous.
or '(?:service detection){0<e<5}$' is also a possibility..
from mrab-regex.
Original comment by Anonymous.
Added in regex 0.1.20120119.
Note that it supports only constraints of the form e<=3 or 1<=e<=3 ("<" is also allowed), but not "=".
from mrab-regex.
Original comment by Anonymous.
thanks ^_^
from mrab-regex.
Related Issues (20)
- Why does this regex formula doesn't work in Python for Find and Replace? HOT 6
- Fuzzy Matching Not Working For Me HOT 1
- regex._regex_core.error: bad inline flags: cannot turn flags off at position 6 HOT 1
- Releases action HOT 1
- Python 3.13 will deprecate Py_UNICODE HOT 1
- Build failure with stricter C compilers on x86 HOT 5
- Feature request: user specified cost function for fuzzy search with BESTMATCH HOT 2
- Request for Detailed Documentation HOT 2
- Fuzzy match with multiple words and different error possibility HOT 1
- segfault when fuzzy matching empty list HOT 1
- `VERBOSE`/`X` flag breaks `\N` escapes HOT 1
- Difference in compiled vs. non-compiled pattern search HOT 3
- hangs with fuzzy and optionals HOT 4
- Get all subscript matches as a list. HOT 2
- Regex fails Unicode 15.1 GraphemeBreakTest due to missing new GB9c rule implementation HOT 1
- Wrong Katakana unicode script HOT 7
- Default value for `allcaptures`, `capturesdict` when no matches? HOT 1
- Bug: Partial matching fails on a simple example HOT 1
- Release 2024.07.24 cannot be installed HOT 4
- [bug] compiled regex patterns not compatible with pandas HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mrab-regex.