TXT2REGEX(1)

🌸 TXT2REGEX β€” the console regular expression wizard ✨

okay bestie, sit down, we're learning txt2regex, which lives in the General Commands Manual section (that's section 1, iykyk) and is genuinely one of the most underrated glow-ups in Unix history πŸ’…


✨ NAME ✨

txt2regex β€” console regular expression wizard 🧚


πŸŽ€ SYNOPSIS πŸŽ€

txt2regex [--nocolor|--whitebg] [--all|--prog programs]

txt2regex --showmeta

txt2regex --showinfo program [--nocolor]

txt2regex --history value [--all|--prog programs]

txt2regex --make label [--all|--prog programs]

like… five whole moods. pick your fighter πŸ’–


πŸ¦‹ DESCRIPTION πŸ¦‹

So txt2regex is a regular expression wizard that converts human sentences into regexes. that's the whole vibe. you type the thing you mean in people-words, it hands you back the regex. no cap πŸ”₯

In a simple interactive console interface, the user answers questions and txt2regex builds the regexes for more than 20 programs. twenty. plus. programs. one wizard. iconic behavior honestly πŸ‘‘

the project lives at https://aurelio.net/projects/txt2regex/ β€” go say hi, it's giving main character energy 🌈


πŸ’œ OPTIONS πŸ’œ

  • --all β€” selects all the available programs. ⚠️ but bestie, be aware that the list of available programs is long. you will need a terminal window with more than 40 lines for the user interface to fit. also make sure that the $LINES shell variable is exported, so txt2regex can detect the current number of available lines. do not skip that step, fr fr 😭
  • -h, --help β€” print the help message and quit. the classic. the beloved. 🫢
  • --history <value> β€” print a regex from the given history data. the history value is shown in the last screen of the wizard, when you quit. so don't close the terminal like a gremlin, screenshot it first πŸ“Έ
  • --make <label> β€” print a ready regex for the specified label. inform an empty label to see the list of available labels. yes, empty. like, nothing. that's the cheat code πŸŽ€
  • --nocolor β€” do not use colors. (respect. some terminals are just going through it) 🚫🌈
  • --prog <program1,program2,...> β€” specify which programs to use, separated by commas. use --showmeta to see the complete list of available programs. pick your squad πŸ’…
  • --showinfo <program> β€” print regex-related info about the specified program. use --nocolor to have a text-only output (no control characters). clean, plain, ✨unbothered✨
  • --showmeta β€” print a metacharacters table featuring all the programs. this is the big one. the group photo. πŸ“Š
  • -V, --version β€” print the program version and quit. short and sweet, love that for it ⭐
  • --whitebg β€” adjust colors for white background terminals. because your eyes deserve nice things πŸ¦‹

🌈 EXAMPLES 🌈

Using it as a wizard (interactive interface):

txt2regex

Specify a custom selection of programs for the wizard:

txt2regex --prog perl,python,php,javascript

Getting an extensive metacharacters table:

txt2regex --showmeta

Getting regex-related information about sed:

txt2regex --showinfo sed

Replay a regex by using history data:

txt2regex --history '16421Β€:01Β€:'

Getting handy ready-to-use regexes for common patterns:

txt2regex --make hour
txt2regex --make number3 --prog perl
txt2regex --make date2 --all

look at that last one going --all like a boss 😌 slay.


πŸ‘‘ WIZARD INTERFACE πŸ‘‘

here's the layout of the whole thing, bestie. this is your screen:

+---------------------------------------+
| Top menu                              |
| Group menu                            |
|                                       |
| Regexes of the selected programs      |
| ...                                   |
| ...                                   |
|                                       |
| History                               |
| Prompt                                |
|                                       |
| The question                          |
| The answers                           |
| ...                                   |
| ...                                   |
+---------------------------------------+

Top menu, group menu, the regexes of the selected programs, history, prompt, the question, the answers… it's a whole little world in there 🌸


πŸ’… WIZARD COMMANDS πŸ’…

these are the keys you press while you're inside the wizard. memorize them, they're your love language:

  • . β€” quit the program (with confirmation). it asks first because it's polite πŸ₯Ί
  • 0 β€” reset the regular expression. fresh start, clean slate, new me 🧼
  • 1-9 β€” answers the questions. nine whole answers at your fingertips πŸ”’
  • * β€” toggles color ON/OFF 🌈
  • / β€” add/remove programs βž•βž–
  • | β€” insert an alternation (where allowed) πŸ”€
  • ( β€” open a new group (where allowed) πŸ“‚
  • ) β€” close the opened group (if any) πŸ“
ok real talk: |, ( and ) say "where allowed" for a reason β€” you can't just spam them anywhere, the wizard will tell you. and ) only does something if there's a group open, so don't be out here closing nothing πŸ’€

πŸ’€ BUGS πŸ’€

found a bug? not me being dramatic but… https://github.com/aureliojargas/txt2regex/issues β€” that's the place. report it there, bestie, the maintainers wanna know πŸ™ˆ


🫢 AUTHOR 🫢

Aurelio Jargas <verde@aurelio.net> β€” the legend themselves πŸ’–


Copyright Β© 2001-2020 Aurelio Jargas, GNU GPL v2 πŸŽ€


and that's the whole page!! this one's from the General Commands Manual gang (TXT2REGEX(1)), dated May 21, 2020, and that's a wrap β€” go build some regexes, you absolute icon πŸ‘‘βœ¨