We can use this literal to represent a compiled pattern, for example:
>>> p"(?i)[a-z]".findall("a1B2c3")
['a', 'B', 'c']
>>> compiled = p"(?<=abc)def"
>>> m = compiled.search('abcdef')
>>> m.group(0)
'def'
>>> rp'\W+'.split('Words, words, words.')
['Words', 'words', 'words', '']
This allows pe
On Thu, Dec 27, 2018 at 10:49 PM Ma Lin wrote:
>
> We can use this literal to represent a compiled pattern, for example:
>
> >>> p"(?i)[a-z]".findall("a1B2c3")
> ['a', 'B', 'c']
>
> >>> compiled = p"(?<=abc)def"
> >>> m = compiled.search('abcdef')
> >>> m.group(0)
> 'def'
>
> >>> rp'\W+'.spli
> It'd be good to know just how much benefit this precompilation
actually grants.
As far as I know, Pattern objects in regex module can be pickled, don't
know if it's useful.
>>> import pickle
>>> import regex
>>> p = regex.compile('[a-z]')
>>> b = pickle.dumps(p)
>>> p = pickle.loads(b)
> W
> We can use this literal to represent a compiled pattern, for example:
>
> >>> p"(?i)[a-z]".findall("a1B2c3")
> ['a', 'B', 'c']
There are some other advantages to this. For me the most interesting is that we
can know from code easier that something is a regex. For my mutation tester
mutmut I
Ma Lin schrieb am 27.12.18 um 14:15:
>> It'd be good to know just how much benefit this precompilation actually
> grants.
>
> As far as I know, Pattern objects in regex module can be pickled, don't
> know if it's useful.
>
import pickle
import regex
That's from the external regex packa
On Fri, Dec 28, 2018 at 12:15 AM Ma Lin wrote:
>
> > It'd be good to know just how much benefit this precompilation
> actually grants.
>
> As far as I know, Pattern objects in regex module can be pickled, don't
> know if it's useful.
>
> >>> import pickle
> >>> import regex
> >>> p = regex.com
On 2018-12-27 11:48, Ma Lin wrote:
[snip]
2, We can't use regex module as a drop-in replacement: import regex as re
IMHO, I would like to see regex module be adopted into stdlib after
cutting off its "full case-folding" and "fuzzy matching" features.
I think that omitting full casefolding would
On Thu, Dec 27, 2018 at 05:47:46PM +, MRAB wrote:
> On 2018-12-27 11:48, Ma Lin wrote:
> [snip]
> >2, We can't use regex module as a drop-in replacement: import regex as re
> >IMHO, I would like to see regex module be adopted into stdlib after
> >cutting off its "full case-folding" and "fuzzy m