Skip to content

Commit c46633d

Browse files
authored
Update README.md
1 parent f86c0ef commit c46633d

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,24 @@
11
# Python-Regex
2-
A port of the Rust regex library to python for super speed linear matching.
2+
A port of the Rust regex library to python.
3+
4+
This package aims to provide complete coverage of the [regex](https://github.com/rust-lang/regex) crate in Rust giving you all the advantages it brings:
5+
> An implementation of regular expressions for Rust. This implementation uses finite automata and guarantees linear time matching on all inputs.
6+
7+
Thanks to the linear time matching it allows Python-Regex to be roughly the same speed as the standard library for non-complicated or large matches while being able to cut matching times for large and complicated expressions into fractions of what they were.
8+
9+
## Example of where it excells
10+
11+
In this examplew we use this regex pattern for selecting HTML tags.
12+
13+
In this case when benched on a large chunk of HTML the Rust port took just `13ms` as a max value compared to Python's `116ms` value that grows almost exponentially as the text size increases.
14+
15+
```py
16+
import regex
17+
18+
exp = regex.Regex(
19+
r"(<script(\s|\S)*?<\/script>)|(<style(\s|\S)*?<\/style>)|"
20+
r"(<!--(\s|\S)*?-->)|(<\/?(\s|\S)*?>)".replace("\/", "/")
21+
)
22+
23+
exp.find("<Some HTML here>")
24+
```

0 commit comments

Comments
 (0)