125. Using Regexes With EzeScan
Regular Expressions (Regexes) may be used to manipulate captured data in EzeScan. For example - formatting dates; removing unwanted characters; replacing data with something else.
Regexes have some common anchors, character classes, quantifiers etc. Here are a few:
* | Identifies that there can be none, one or more of the preceding item |
+ | identifies that there must be one or more of the preceding item |
^ | Is for the start of the search text, e.g. ^0* would find leading 0's |
. | Is used to match any character |
$ | Is for the end of the search text |
\b | Is used to identify the start and end of a word |
| | Is the OR separator this means we can look for multiple words |
\ | Is an escape character. It can be used to remove a character that is used in regex codes |
These are a few examples of Regexes commonly used within EzeScan:
TIP: The REGEXs in this section may be copied and pasted straight into the EzeScan REGEX editor. Drag your mouse across the values from the first " to the last "
for example "^0*(\d*)-(\d*)( - .*)","$1$2$3" The blue text represents the values to be replaced and the red text represents what the text is being replaced with the blue text.
Replace the 3rd and 6th character with a /
This is handy if an OCR has picked up the / in a date as a 1 e.g. 12112112 will become 12/12/12
Regex = "^(..).(..).","$1/$2/"Keep the first value where it is delimited with two pipes (|)
e.g. PO1234||0||1 will become P01234
Regex = "^([^\|]+).*$","$1"This will add a .00 if there is no decimal value. If there is a decimal value it will leave as is
e.g. 100 will become 100.00 but 100.45 would remain as 100.45
Regex = "(?!\s-?\d+\.\d+|^-?\d+\.\d+)(\s-?\d+\b|^-?\d+\b)","$1.00"Clear out the whole value if it ends with a \
e.g. "ezescan\" will become blank (null) whereas "ezescan" will remain as "ezescan"
Regex = "^.*\\+$",""Set a value to error if a numeric value has a minus
e.g. 1 or 1.00 will be OK whereas -1 or -1.00 will change the value to error
Regex = "-[0-9]+\.?[0-9]*","error"Remove the first two characters out of a value
e.g. "BA123456" will become "123456"
Regex="^..",""
Tip - add more dots to remove more charactersConvert a HP RM/TRIM KFI browse value to just output the first name and last name
e.g. "Citizen, John (Mr) -lu 1660" will become "Jon Citizen"
Regex = "-(lu [0-9]+)",""," *([(][^()]*[)])","","([^,]+),([^,]+)","$2$1","^ *",""To remove the word VIC and any words after it
e.g. "1 Smith St VIC" will become "1 Smith St"
Regex = "^(.*)\sVIC\s.*$","$1"
Note - Change the value VIC to NSW or QLD etc for other states
Suggested Regex Resources
If you are new to using Regexes we suggest you take a look at these resources on the internet.
http://www.cheatography.com/davechild/cheat-sheets/regular-expressions/
Regular Expressions Cheat Sheet by Dave Child - A quick reference guide for regular expressions (regex), including symbols, ranges, grouping, assertions and some sample patterns to get you started.http://www.regexbuddy.com/
Learn, Create, Understand, Test, Use and Save Regular Expressions with RegexBuddy
You could buy a copy of RegexBuddy from the program's Authors.Install and license it onto your PC where EzeScan is installed.
Start EzeScan & edit a KFI field → use one of our Regex Edit buttons to start up our 'Edit Regex' form. For example, the window below appears when working with a KFI Discovery field.
Then press the 'Editor' button (if it's grayed out tick the 'Use' button below it to enable it).
Ezescan will launch RegexBuddy if you have it installed on your PC.
Any regex entered into RegexBuddy will be automatically transferred to the corresponding regex field on the EzeScan Edit Regex form when you close RegexBuddy.