1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
|
txt2regex
aurelio@verde666.org
2002-03-04
a Regular Expression "wizard", all written with bash2 builtins
^txt2regex$ is a Regular Expression "wizard", all written with bash2
builtins, that converts human sentences to RegExs. with a simple
interface, you just answer to questions and build your own RegEx for a
large variety of programs, like awk, emacs, grep, perl, php, procmail,
python, sed and vim. there are more than 20 supported programs.
it's bash so download and run, no compilation needed.
----------------------------------------------------------------------
WHY?
- to try to make simple RegExs less painful for the beginners
- to have a reliable source for RegExs differences between programs
- to have coding fun &:)
WHY BASH2?
basically, for me to learn the new bash2 concepts as arrays, i18n and
advanced variable expansion. they rule!
----------------------------------------------------------------------
INSTALL AND RUN
after expand the tarball, do you can simply run the program directly.
but if do you want it on your system, or in other language besides
english, use make.
Summary
- just english: untar and run
- with i18n: untar, make install and run
untar
tar xvzf txt2regex-VERSION.tgz
cd txt2regex-VERSION
run
./txt2regex.sh
make install
if you're root and wants to install it on the system, with i18n:
make install
/usr/bin/txt2regex
or, if do you want to use it on locally, on the txt2regex dir, with
i18n:
make install BINDIR=. LOCALEDIR=po
./txt2regex
if you want to install it on another location, redefine BINDIR,
LOCALEDIR and DESTDIR variables.
----------------------------------------------------------------------
HOW TO USE IT?
first of all, do accept the truth:
- only works in bash >= 2.04
- only works in bash >= 2.04
- only works in bash >= 2.04
just run it and see the it's face.
the interface is pretty easy to understand, but in short, it's:
+---------------------------------------+
| -> top menu |
| -> group menu |
| |
| -> RegExs of the programs selected |
| ... |
| ... |
| |
| -> history |
| -> your prompt |
| |
| -> the question |
| -> the answers |
| ... |
| ... |
+---------------------------------------+
so, using the numeric pad on the keyboard (there, on the right side),
press the numbers to choose the answers (turn NumLock on!) and just
see the RegExs being made.
as the top menu says, press . to quit and 0 (zero) to reset the
RegEx. the * key toggles color ON/OFF and / add/remove programs
on the RegEx part. just it.
the group menu is contextual, it appears on the 2nd line when needed.
so, in short:
- read the question
- choose the answer
- press the number
- fun!
_______________________________________
COMMAND LINE
there's a few command line options, see the --help:
+--------------------------------------------------------------------+
| |
| usage: txt2regex [--nocolor|--whitebg|--all] |
| txt2regex --showmeta|--showinfo <program> |
| txt2regex [--all|--prog <p1,p2>] --make <target> |
| txt2regex --history <value> |
| |
| OPTIONS (they are default OFF): |
| |
| --all works with all registered programs |
| --nocolor self-explanatory |
| --whitebg colors adjusted to white background |
| terminals |
| --showmeta prints a complete metachar table for all |
| programs |
| --showinfo <program> prints regex info about the program |
| |
| --history <value> prints to STDOUT a RegEx from a history data|
| --make <target> prints a ready RegEx for a common pattern |
| --prog <p1,p2,...> choose which programs to use |
| |
| |
| for more details about the options, read the README file. |
| |
+--------------------------------------------------------------------+
and as we're on the README file, here are the details:
- --all is cool but requires lots of lines (~35)
- --nocolor is strong, so it kills --whitebg
- --whitebg is a requirement of X users, and as i don't use X, tell me
if anything is wrong
- --showmeta rules, try it
- --showinfo has a reverse video nice output, if you don't like it, do
use it with --nocolor
- --history is getting useful, stay tunned
- --prog is nice to specify your favorite programs
- --make is a remedy for headaches
and now what you've waiting for, the examples:
* just calling it
txt2regex
* calling the program on a white terminal
xterm -fg black -bg white
txt2regex --whitebg
* getting information
txt2regex --showmeta
* getting specific information
txt2regex --showinfo sed
* calling it for specific programs
txt2regex --prog vim,sed,grep,python
* applying a history data
txt2regex --history '16421:01:'
* getting ready RegExes!
txt2regex --make hour
txt2regex --make number3 --prog perl
txt2regex --make date2 --all
----------------------------------------------------------------------
INFO ABOUT THE INFO ON IT
all RegExes and rules the program knows about were extensively tested
by hand or by the test-suite program. when the program can't be
reached or executed on my machine, the rules were taken:
- from the program documentation
- or missing it, from the "mastering regular expressions" o'reilly book
- or missing it, from internet documents (oh no!)
programs that were tested here:
- ed: GNU ed version 0.2
- mawk: mawk 1.3.3 Nov 1996
- gawk: GNU Awk 3.0.6
- grep: grep (GNU grep) 2.4.2
- egrep: egrep (GNU grep) 2.4.2
- find: GNU find version 4.1
- javascript: netscape-4.77
- mysql: Ver 11.13 Distrib 3.23.36
- perl: v5.6.0 built for i386-linux
- php: 4.0.6
- postgres: psql (PostgreSQL) 7.1.2
- procmail: procmail v3.15.1 2001/01/08
- python: Python 2.1
- sed: GNU sed version 3.02.80
- tcl: 8.3
- vi: Nvi 1.79 (10/23/96)
- vim: VIM - Vi IMproved 5.8 (2001 May 31)
----------------------------------------------------------------------
IF YOU REALLY LIKE IT
use it and tell your friends.
yes, it's GPL.
----------------------------------------------------------------------
BUGS, IMPROVEMENTS AND CONTRIBUTIONS
they're VERY welcome! send to the author (e-mail below).
a cool (and easy/fast to do) contribution is a translation of the
program messages to your own language. get the po/txt2regex.pot file
and translate it. in doubt, ask.
----------------------------------------------------------------------
TRANSLATIONS MAINTAINERS
"i feel like i could... like i could... TAKE OVER THE WORLD"
en english the author
pt_BR brazilian portuguese the author
id_ID bahasa indonesian Muhamad Faizal
pl_PL polish Chris Piechowicz
de_DE german Jan Parthey
ja japanese Hajime Dei
----------------------------------------------------------------------
FAQ
- Q: my screen has more than 25 lines, i'm serious!
- Q: why it only uses 80 columns if my screen has more?
- Q: i've changed the xterm window size, why it didn't notice that?
- A: the program do use the bash environment variables $LINES and
$COLUMNS to get the actual screen size. those MUST be exported
variables, or you'll be stucked at the default 80x25 size. try:
/bin/bash -c 'echo $COLUMNS $LINES'
if you don't get the screen size, do:
echo export COLUMNS LINES >> ~/.bash_profile
- Q: why my bash version is not recognized correctly?
- Q: here bash --version is >=2.04. why the program gets other?
- A: to find your bash version, the program uses the $BASH_VERSION
environment variable that is available in all bash versions.
if some alien has possessed your machine and your environment
don't have this variable, try to set it by hand. check with
echo $BASH_VERSION
if this variable is ok, but bash --version returns other
version, check if your bash is really /bin/bash:
which bash
if it's not /bin/bash, you MUST change the first line
of the script to your bash's right path. suppose you have the
bash binary in your $HOME because the system's bash is old,
just change the first line of the program to:
#!/home/YOU/bin/bash
or if you cannot change the program file, call it with bash:
bash ./txt2regex
sux, but worx.
- Q: what is that <TAB> that appears when i choose TAB on the special
combination menu?
- A: inside lists [], the <TAB> string is a visual representation of
a literal TAB character, for programs wich doesn't support [\t].
----------------------------------------------------------------------
ABOUT THE AUTHOR
who cares?
----------------------------------------------------------------------
--
AUTHOR: aurlio marinho jargas <aurelio@verde666.org>
DEBUT: 20010223
URL: http://txt2regex.sourceforge.net
|