Skip to content
Match up to a symmetry

Match up to a symmetry

Match up to a symmetry

Match text that is the same up to case, notation, word shape or a typed relation rather than byte for byte. The groups are on the orbit page.

Every spelling of a word

(?orbit:case ...) compares every literal inside it with case folded:

$ trex scan '(?orbit:case "error")' --text 'Error: disk; ERROR: net; error: cpu'
[0..5] "Error"
[13..18] "ERROR"
[25..30] "error"

A later token equal up to a symmetry

=G name matches a token equal to the one name bound under group G: =shape the same consonant and vowel pattern, =case the same letters, =subnet an address in the same network.

$ trex scan '\W:w =shape w' --text 'cat bat xyz'
[0..7] "cat bat"  captures: w="cat"

$ trex scan '\I:a .*? =subnet a' --text 'from 10.0.0.1 to 10.0.0.77 and 192.168.1.1'
[5..26] "10.0.0.1 to 10.0.0.77"  captures: a="10.0.0.1"

=subnet reads a /24 network for IPv4 and /64 for IPv6, and =subnet/16 a names the width. Every typed relation is in the pattern syntax.

Count the forms of a vocabulary

$ trex orbit --collapse --group case --text 'Error ERROR error warn WARN'
trex orbit --collapse (group case): 5 raw forms -> 2 orbits (2.5x reduction)
    "error"  <-  ["ERROR", "Error", "error"]
    "warn"  <-  ["WARN", "warn"]