Working with Regular Expressions is a great way to scan data for strings that meet certain conditions. Instead of a simple find with an exact match, you can look for matches with the same pattern such as: only numbers, strings with x characters, strings that start with a specific character etc. Regex is also useful for validity tests, is a number a valid phone number or is a string a valid email address.
If you're familiar with regex basics then CodVerter's Multiple Regex Pattern Scanner can assist you with advancing your regex usage.
Multiple Regex Patterns
One of the tool main advances is the ability to handle more than one regex pattern at a time.
Why is this useful? Yes, you can use the "Or" regex condition (|), but in that case you won't
be able to identify which part of the pattern's condition is the one that matches the data,
or perhaps if there's an overlap and a string matches more than one condition.
By adding regex patterns one by one to a table you can track all the patterns easily.
Sample of Regex patterns table
Detect Mode
This mode is used for identifying and finding matches results. Each pattern added to the table is marked in the editor in a different color. "Append Name" option adds the names of patterns found at the end of each line. This is useful if your data is copied from Excel or a tab delimited file, then you can copy-paste it back. Try "Detect" mode on Multiple Regex Pattern Scanner.
Sample of Detect mode output with Append Name
Extract Mode
This mode transforms your data and leaves only strings that matches patterns entered to the table. The extracted data is available for every match found in source data. Output data is in a semicolon (;) delimited format, where each line contains the following:
- Matched String - string found in text
- Line - number of line in source data (starting from 1)
- Index in Line - starting index in line (starting from 0)
- Index in Text - starting index in source data (starting from 0)
Sample of Extract mode output
Concatenate Mode
Adds text before and/or after a pattern's match. You can edit patterns in the table or add new ones with text to concatenate to them. Try "Concatenate" mode on Multiple Regex Pattern Scanner.
Sample of Regex patterns table with concatenation data
Sample of Concatenate mode output
Replace Mode
In this mode you can replace patterns' matches with a text of your choice. This comes in handy when you need to hide data for security reasons for example. You can edit patterns in the table or add new ones with text to replace them with. Try "Replace" mode on Multiple Regex Pattern Scanner.
Sample of Regex patterns table with replace data
Sample of Replace mode output
Analyze Mode
This mode presents a summary with amount of times each pattern was found in data, and what are the matches found how many times they appear. Try "Analyze" mode on Multiple Regex Pattern Scanner.
Sample of Analyze mode output
Regex Flags
Before submitting for an output you can choose regex modifiers by pressing the "Change Flag" button and selecting from the list:
List of regex flags
Let's
CodVert!
Author: Noga @CodVerterTeam
Date: 4 December 2018