Regex, or the short term for Regular Expressions, is a short representation for a set of strings (certain amount of text). These sets are a great way of filtering data in a complex manner, but because there are a variety of steps to follow, they can be a bit tricky to put into work.
The most common uses for Regular Expressions are:
Verifying string structure
Extracting substrings from a set of strings already structured
Finding, replacing and/or rearranging string parts
Splitting strings into other sets
Since Regex works on characters, not words, here are some examples (with visuals) on how to find, replace, and check different errors in a general translation (for different languages):
Find and Replace- A replacement text is that which each regular expression match is replaced with when searching for an error.
Option 1:
(?<![a-zA-Z\)]) (?=\d)
Option 2 (use this to work around the bug in Trados regarding lookahead and lookbehind functions.):
Find ([^a-zA-Z)]) (\d)Replace $1,$2
FR to EN: Find any space between two numbers in the target. Replace with a comma.
Test with https://regex101.com/
\u00BF|\u00A1
ES to EN: Find ¡ or ¿ in the target, replace with nothing.
Error Checking- Decide what errors to correct (in this case allowing numbers as your character type).
(^(\d{1,2})(?=\/))
EN-GB to EN-US: Check numbers before the first slash in a date. Report Error if it’s the same.
Test with https://regex101.com/
Checking French quotation mark errors
("\s)|(\s")|('\s)|(\s')
EN to >FR: Check English or American quotation marks, preceded by or followed by a space, to avoid the apostrophe (‘). Report Error if it’s the same.
Test with https://regex101.com/
Summary:
In this blog, we provided character examples to look for and replace (or erase) when using Regex
Commas “,”
Exclamation and question marks (for ES) “¡!” “¿,?”
Numbers
Quotation marks errors (for FR) “ ‘ ”
Comments