You can "install" it in the browser's menu. It's a Progressive Web App for the desktop, Cross-Platform.
>> >> >> >> >>x - +
Try some example, click on the links below and watch the Regex result:
FInd the names of models on the page https://en.wikipedia.org/wiki/Terminator_(character). Simplified.
1. model name - T- Find occurrences of this 2 literals.
2. model name - T-\d+ After that are one or more digits.
3. model name - T-(X|\d+) There are always some exceptions, the T-X model.
It also replaces T- with the word Robot().
4. XML - <title>(.+?)</title> Find titles - not greedy.
5. XML - <year>(1[89]\d\d)</year> Find old years.
6. XML - <year>(2\d{3})</year> Find new years.
7. Just a simple email validation - ^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$
- +
//comment
println!("{}","one");
x - +
//comment
println!("{}","one");
x - +
//comment
println!("{}","one");
x - +
1. copy
2. play
//comment
println!("{}","one");
x - +
Basic Regex syntax
abc… Letters literally
123… Digits literally
[abc] Only a, b, or c
[^abc] Not a, b, nor c
[a-z] Characters a to z
[0-9] Numbers 0 to 9
\w Any Alphanumeric character
\W Any Non-alphanumeric character
\d Any Digit
\D Any Non-digit character
Quantifiers:
? Zero or one repetition
* Zero or more repetitions
+ One or more repetitions
{m} m Repetitions
{m,n} m to n Repetitions
\s Any Whitespace
\S Any Non-whitespace character
. Any Character (avoid using)
\. Period - escaped
^…$ Starts and ends
Capture groups:
(…) Capture Group
(?:…) Non-Capture Group
(a(bc)) Capture Sub-group
(.*) Capture all
(abc|def) Matches abc or def
Substitution:
$1, $2 Captured group Substitution
Flags:
(?m) Multiple line matching (^$ -start/end of line)
(?i) Case insensitive match
(?U) Sets the engine to lazy matching - ungreedy
Avoid using .* dot (any character many times) because it is greedy.
Instead use a negation of the next delimiter like [^/]*.
If needed, add Flags in the beginning like (?m) Multiple line matching.
Regex or Regular expressions is a special programming language for search, match, validate and replace sub-strings.
It looks very cryptic. But it is powerful and you should use it. Look how crazy this is:
^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$
DON'T PANIC ! Try it !
On every key-up in the Regex section, this PWA will calculate and show you the explanation, result of Regex methods and generate the Rust code with that Regex.
Use this web app when you are coding in Rust and need to write a Regex. Enter your Regex, substitution and test_string.
Change your Regex gradually and observe the result. Great way of interactive learning!
The Regex explanation is 100% human readable. Easy like that!
Use the examples to fast see it all working. From simplest to more complex gradually.
Click Copy and then Play in the code-gen section. In play.rust-lang.org paste the generated code and click Run to see it live in action.
If you need more or less space, click on the + and - symbols.
This PWA (progressive web app) runs entirely inside your browser with 100% pure Rust Wasm/WebAssembly.
The web server only provides the files. No code is executed on the server.
This means you can use this web app offline. No need for internet connection, except for downloading the code the first time. PWA are used a lot in mobile, but this PWA is meant to be used in the desktop browser.
Regex has many many features, therefor libraries are never 100% compatible. This "flavors" have differences that are subtle, but important for practical use. The Rust code of this app uses the Rust Regex library: https://docs.rs/regex/
Cargo.toml: regex = "1.3.9", regex-syntax="0.6.18"
If you use the same Regex library in you project, this PWA will show you exactly how Regex will work in your code.
Repository: https://github.com/bestia-dev/rust_regex_explanation_pwa/
Version: 1 License: MIT
Donate: paypal.me/LucianoBestia