Skip to main content

Searching with Regular Expressions and Wildcards

Introduction

The Power Search Bar is an indispensable tool that enables users to locate source text and translations through the application of regular expressions and wildcards. While this feature offers a robust and flexible search experience, it's crucial to be aware that not all operators are supported. Refer to this documentation for a list of supported operators and examples of their usage.

Regular Expressions (Regex)

Regular expressions utilize placeholder characters, referred to as operators, to match patterns within data and text. Wordbee’s library supports all Unicode characters but reserves some of them to be regex operators:

CODE
" . ? + * \ { } | ( ) [ ] ^ 

" If you include a double quotation mark in your regular expression pattern, it is used to match the exact occurrence of that character in the text you are searching. For example:

CODE
"example" will match the word 'example'

. Matches any character. For example:

CODE
ab.     will match 'aba', 'abb', 'abz', etc.

? Indicates that the preceding character is repeated zero or one times. Often used to make the preceding character optional. For example:

CODE
abc?     will match 'ab' and 'abc'

+ Indicates that the preceding character is repeated one or more times. For example:

CODE
ab+     will match 'ab', 'abb', 'abbb', etc.

* Indicates that the preceding character is repeated zero or more times. For example:

CODE
ab*     will match 'a', 'ab', 'abb', 'abbb', etc.

\ A backslash is used as an escape character to indicate that the character following it should be treated as a literal character and not a regex operator.

CODE
\.     will match '.' instead of any character (see above)

{} In braces users can define the minimum and maximum number of times the preceding character can repeat. For example:

CODE
a{2}    will match 'aa'
a{2,4}  will match 'aa', 'aaa', and 'aaaa'
a{2,}   will match 'a` repeated two or more times

| OR operator. The match will succeed if the longest pattern on either the left side OR the right side matches. For example:

CODE
abc|xyz  will match 'abc' and 'xyz'

( … ) Parantheses can be used to form groups within regular expressions. You can use a group to treat part of the expression as a single character. For example:

CODE
abc(def)?  will match 'abc' and 'abcdef' but not 'abcd'

[ … ] Brackets are used to match one of the characters within them.
Inside brackets, - indicates a range unless - is the first character or escaped. For example:

CODE
[abc]   will match 'a', 'b', 'c'
[a-c]   will match 'a', 'b', or 'c'
[-abc]  will match '-', 'a', 'b', or 'c'
[abc\-] escapes '-' and will match 'a', 'b', 'c', or '-'

A ^ before a character in the brackets negates the character or range. For example:

CODE
[^abc]      will match any character except 'a', 'b', or 'c'
[^a-c]      will match any character except 'a', 'b', or 'c'
[^-abc]     will match any character except '-', 'a', 'b', or 'c'
[^abc\-]    will match any character except 'a', 'b', 'c', or '-'

Wildcards

Wildcards are placeholders in computing that can stand in for any character or group of characters, making it easier to find or match different variations of a word or phrase. These so called wildcard operators match one or more characters and can be combined with each other to create a wildcard pattern.

? You can use the questionmark to match any single character. For example:

CODE
locali?ation      will match 'localization' and 'localisation'

* You can use the asterisk to match zero or more characters. For example:

CODE
translation*      will match 'translation', 'translations', 'translation-based' etc.

“Phrase match” is unticked then the editor will prefix and suffix your typed text with “*”. Example: You type “hello”, the search to ElasticSearch will be “*hello*”

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.