Tips of this tool
Sponsored Links
Generate regex automatically, quickly, correctly
Introduction
In many cases, the regex which we will write is not so complex and abstract, but it is too many and too long. For example, if we need to write a regex to match HTML. So, we can use this tool to generate regex quickly, simply and correctly.
Wildcard
Wildcard is the asterisk(*) which we used to list text files start with 'a': C:\> dir a*.txt. The wildcard means it can be anything here. This tool is to convert Wildcard to Regex.
In order to get and save the content which wildcard matches, we designed "Named wildcard": that is *{name:XXXX} format. But if it conflicts with your normal content, you can select another wildcard format in the front.
Steps
We can write a pattern with wildcard directly, for example 'a*.txt'. In more cases, we copy a piece of target text, HTML source code, and modify the vary part to wildcard.
- Open browser and browse the target page, find what we want.
-
Open HTML source code, find the corresponding HTML source. For example:
<tr class="odd"> <td>Name: Tom</td> <td>Age: 29</td> </tr>
-
Mofidy the vary part to Wildcard: (If we want to save, use *{name:XXX} format, else use * )
<tr *> <td>Name: *{name:Name}</td> <td>Age: *{name:Age}</td> </tr>
-
Input the pattern into "Pattern contains wildcard" box and click "Get regex", we get:
<tr\s+(?:(?!>\s+<td>Name\:\s+)(?:.|\n))+>\s+<td>Name\:\s+((?:(?!</td>\s+<td>Age\:\s+)(?:.|\n))+)</td>\s+<td>Age\:\s+((?:(?!</td>\s+</tr>)(?:.|\n))+)</td>\s+</tr>