Questions tagged [pypi-regex]

Regex module for Python without the limitations of re. This module has many features like: atomic groups/possessive quantifiers, variable length lookbehind, repeated captures, fuzzy match, recursion, backtracking control verbs; and many convenient methods.

https://pypi.python.org/pypi/regex

12 questions
12
votes
2 answers

Fuzzy regex (e.g. {e<=2}) correct usage in Python

I am trying to find strings which are at most two mistakes 'away' from the original pattern string (i.e. they differ by at most two letters). However, the following code isn't working as I would expect, at least not from my understanding of fuzzy…
Anon
  • 619
  • 1
  • 9
  • 18
6
votes
1 answer

How can I find the best fuzzy string match?

Python's new regex module supports fuzzy string matching. Sing praises aloud (now). Per the docs: The ENHANCEMATCH flag makes fuzzy matching attempt to improve the fit of the next match that it finds. The BESTMATCH flag makes fuzzy matching…
zelusp
  • 3,500
  • 3
  • 31
  • 65
4
votes
2 answers

Python "regex" module: Fuzziness value

I'm using the "fuzzy match" functionality of the Regex module. How can I get the "fuzziness value" of a "match" which indicates how different the pattern is to the string, just like the "edit distance" in Levenshtein? I thought I could get the…
tslmy
  • 628
  • 1
  • 6
  • 21
4
votes
1 answer

Creating fuzzy matching exceptions with Python's new regex module

I'm testing the new python regex module, which allows for fuzzy string matching, and have been impressed with its capabilities so far. However, I've been having trouble making certain exceptions with fuzzy matching. The following is a case in point.…
user1185790
  • 623
  • 8
  • 24
3
votes
1 answer

compiling a fuzzy regexp with python regex

When I found out that the python regex module allows fuzzy matching I was increasingly happy as it seemed as a simple solution to many of my problems. But now I am having a problem for which I did not find any answers from documentation. How could…
2
votes
1 answer

How does adding some text make this regex match the input even though there's no lookahead?

While working on an answer to this question, I came up with this regex: (?:(?!\2)(?:,foo=([^,]*),(?=())|.))*\2bar=2 (Note: this regex requires the PyPI regex module) (Short explanation: The regex relies on the fact that capture groups in lookaheads…
Aran-Fey
  • 39,665
  • 11
  • 104
  • 149
2
votes
1 answer

Recursive Regex with a Pattern Matching only on Start of Match before Recursion?

I'm trying to find matching parentheses where there are also some more in the middle. I have the following regex that does that, it matches the parenthesis to find the one associated with it. What I need now is that it also searches a prefix for…
Jugg
  • 63
  • 3
1
vote
1 answer

Retrieve every times a group matched

Note: I'm using pypi regex module I have the following regex pattern (flags V1 + VERBOSE): (?(DEFINE) (?P[\d-]+) ) id:\s(?&id)(,\s(?&id))* How can I retrieve all the times the group matched ? For example, in the following text: don't…
François
  • 45
  • 1
  • 6
1
vote
1 answer

Ambiguous substring with mismatches

I'm trying to use regular expressions to find a substring in a string of DNA. This substring has ambiguous bases, that like ATCGR, where R could be A or G. Also, the script must allow x number of mismatches. So this is my code import regex s =…
leleonp
  • 67
  • 7
1
vote
1 answer

New regex module fuzzy function error value. Python

im trying out the fuzzy function of the new regex module. in this case, i want there to find a match for all strings with <= 1 errors, but i'm having trouble with it import regex statement = 'eol the dark elf' test_1 = 'the dark' test_2 = 'the…
O.rka
  • 29,847
  • 68
  • 194
  • 309
0
votes
1 answer

Fuzzy regex matching with python returns empty list

I have made a clumsy first attempt at fuzzy pattern matching using the re module in python 2.7. Unfortunately every attempt I make returns an empty list. I simply don't understand the syntax required. I was wondering if someone might tell me why the…
poppyseeds
  • 421
  • 1
  • 7
  • 14
-1
votes
1 answer

python fuzzy regex with nested or regex

I'm trying to do some fuzzy matching on a string of DNA reads. I'd like to allow for up to 1 substitution error while at the same time allowing a particular basepair to be one of two options (A or G in this case). I've started with the…
Constantino
  • 2,243
  • 2
  • 24
  • 41