Edge Python
Esc

Go to

Commands

Sign In

Sign in to publish packages and pin them by sha256.


By continuing, you accept our Terms and Conditions.

@
Palette

re

0.1.0

Regular expressions with backreferences and lookaround.

@dylan·0 downloads·108.1 KB·needs edge 0.7.3·Repository
edge add re && edge lock
bash

sha256-828e7c2ddf520235ffda8c833fff0fce579abe53ac15b0522afd8ef78da47aa4

Docs

re

re works like Python’s. match anchors at the start, search looks anywhere and fullmatch takes the whole string, and each hands back a Match or None.

<re.Match object; span=(4, 9), match='12-34'>
12-34 12 34
('12', '34') (4, 9) 7
None
Output

Named groups answer by name too, and a group that took no part reads as None.

ana {'user': 'ana', 'host': 'mail'}
(None, 'b')
Output

findall gives the text of every match, or its groups when the pattern has them, and finditer gives each Match with its position.

['1', '22', '333']
[('a', '1'), ('b', '2')]
1 1
22 4
Output

sub replaces with a template, where \1 and \g<name> bring back a group, or with a function that gets each Match. count caps how many, subn also says how many it replaced, and split cuts at every match.

host.user
a2 b44
('a#b#c3', 2)
['a', 'b', 'c']
Output

compile checks a pattern once and hands back a Pattern with the same methods. The flags re.I, re.M and re.S ignore case, anchor at every line and let the dot match a newline, and escape makes any text match as written.

re.compile('hola', re.IGNORECASE) <re.Match object; span=(1, 5), match='HOLA'>
['a', 'b']
1\+1=2\?
Output

A bad pattern raises re.error, which is ValueError here, and a pattern that backtracks without end raises RuntimeError instead of hanging. bytes patterns are not supported.

bad pattern: missing ), unterminated subpattern at position 0
too slow: catastrophic backtracking: O(n^2) time or worse on this input, simplify nested quantifiers
Output

Versions

VersionPublishedSize
0.1.0currentSeptember 28, 2026108.1 KB