Regular Expressions
Regular Expressions can be used in various features in your Localize dashboard.
A number of features in your Localize dashboard allow you to enter a Regular Expression or "regex", including:
- Disable Localize by Page
- Disable Phrase Detection by Page
- Define Variables in Your Dynamic Phrases
- Block New Phrases by Pattern
Example Regular Expressions
The follow are examples of some common Regular Expressions that you might find in your content.
Item | Regular Expression | Examples |
---|---|---|
Date With Slashes | \d{1,2}\/\d{1,2}\/\d{4} | 1/2/2020 12/15/1963 |
Date with Dashes and text-based 3-letter month | \d{1,2}-[A-Z]{1}[a-z]{2}-\d{4} | 11-Jan-2014 5-Apr-1963 |
Date and time | [a-z,A-Z]{3} \d{1,2}, \d{4} \d{1,2}:\d{2} [A,a,P,p][M,m] | Aug 9, 2021 10:20 AM Sep 11, 1964 10:20 pm |
Short time | \d{1,2}:\d{2} [A,a,P,p][M,m] | 12:34 PM 5:14 am |
Countdown Timer (HH:MM:SS) | \d{2}:\d{2}:\d{2} | 12:42:22 01:18:33 |
Brand name or other specific word | Localize | Any phrase whose content contains the string literal "Localize" anywhere in it |
Specific ID #s (e.g. US social security #) | \d{3}:\d{2}:\d{3} | 111-22-333 |
Specific word: dog | ^dog$ | Any phrase whose content is exactly "dog" |
Special Characters in Regular Expressions
Special Characters
Regular expressions use special characters (metacharacters) to denote which characters to match in the source content. You must be careful when adding words/phrases to this list so that they aren't interpreted differently than you expect them to be.
The special characters are:
- backslash \
- caret ^
- dollar sign $
- period or dot .
- vertical bar or pipe symbol |
- question mark ?
- asterisk or star *
- plus sign +
- opening parenthesis (
- closing parenthesis )
- opening square bracket [
- opening curly brace {
Escaping
Any special characters that can be used in regular expressions will need to be "escaped" if you want to match the literal character.
For example: If you want to exclude anything with .tif in the phrase, you would enter: \.tif
- The backslash tells the parser to consider the "." as a literal character.
- Without the backslash, the .tif would include any phrase that has at least one character before tif, e.g. any phrase with the word "identify", etc.
Updated 2 months ago