visual-regexp(1) | General Use Manual | visual-regexp(1) |
visual-regexp - graphical front-end to write/debug regular expression
visual-regexp file
visual-regexp is a program that interactively creates and shows the output from regular expressions in Perl. It is ideal for debugging complicated perl expressions.
Helps you to design, debug or more generally work with perl regular expression. As it is often difficult to write the right regexp at the first try, this tool will show you the effect of your regexp on a sample you can choose.
To design regexp, just type the expression in the top text widget. Press the 'Go' button to highlight the matched part of the text in the sample text widget.
To get a quickref of the regexp syntax use the menu 'View/Show regexp help'.
You can specify some options using the checkboxes (please read Tcl help to learn the meaning of these options).
Sometimes you will need more than one step to extract the information you want from the sample. For example, imagine you want to retrieve information from an HTML table inside an another HTML table :
You cannot use one global regexp to extract the two lines "One 1" and "Two 2". You have to use a first regexp to narrow the processed region. Type the following regexp '<table bg[^>]*?>(.*?)</table>' and press 'Go'. You see now that the interesting area is shown in blue. Press the Match '1' button which will extract the blue text (the regexp to use to get this text is then printed on the console). Now use '<td>(.*?)</td>.*?<td>(.*?)</td>' to get the information you need.
<html><body>
<table border=1>
<tr><td>
<table bgcolor="#FFFF00" border=1>
<tr> <td>One</td> <td>1</td> </tr>
<tr> <td>Two</td> <td>2</td> </tr>
</table>
<tr> <td>Foo</td> <td>Bar</td> </tr>
</table>
</body></html>
When you need to match a list of words, use the menu ’Insert regexp/Make regexp' to design an optimized version of the word list.
For example, the list 'aa aab ab ad' is optimized into 'a(ab?|b|d)'.
Can use visual-regexp to perform modification of a text. Just use the menu 'Select mode/Use replace'. You can now design a regexp to match what you want. Then use the replace text widget to enter the substitution you want to apply (use , 1, 2, ... to match the subregexp, use the color to map the number with the matched sub-expressions).
After the substitution, you can save the new text using the 'File/Save ...' menu. You can let the program choose the end-of-line format or force them for a specific environment (Unix, Windows, Mac).
METACHARACTERS
REPETITION
SPECIAL NOTATIONS WITH \
CHARACTER SETS: SPECIALITIES INSIDE [...]
Single characters
\t tab
\n newline
\r return (CR)
\xhh character with hex. code hh
“Zero-width assertions”
\b “word” boundary
\B not a “word” boundary
Matching
\w matches any single character classified as a “word” character (alphanumeric or “_”)
\W matches any non-“word” character
\s matches any whitespace character (space, tab, newline)
\S matches any non-whitespace character
\d matches any digit character, equivalent to [0-9]
\D matches any non-digit character
This program requires Tcl/Tk 8.3.0 or later with the script version. Nothing with the standalone program.
visual-regexp was written by Laurent Riesterer <laurent.riesterer@free.fr>.
This manual page was written by Braulio Henrique Marques Souto <braulio@disroot.org> for the Debian project (but may be used by others).
18 October 2022 | visual-regexp-3.1 |