Getting started
Getting started
Install trex and run a first scan on the surface you use: the command line, Rust, Python or PowerShell.
Install
The package on crates.io is trex-re; the command it installs is trex. It needs Rust 1.96 or
newer. The trex binary for Windows x64, Linux x64, FreeBSD x64 and macOS arm64 is also on the
latest release.
$ cargo install trex-re
$ trex --version
trex 0.2.0
A first scan
A trex pattern matches tokens, not characters. \N is one number token:
$ trex scan '\N' --text 'order 42 shipped'
[6..8] "42"
Each match has its span, start inclusive and end exclusive, and its text. order and shipped
are word tokens, \W, so they do not match.
Two tokens in a row
Whitespace between tokens is not written, so two atoms in sequence match two tokens in a row:
$ trex scan '\N \W' --text 'weight 12 crates'
[7..16] "12 crates"
A number with a unit symbol reads differently: 12 kg is one quantity token, matched by
\{qty}.
Where next
Your first patterns covers the atoms, sequences, alternatives and repetition, everything ordinary matching needs before the parts a regex cannot express.