How to use RegEx (Regular Expressions) with FocusMe
FocusMe supports using Regular Expressions for advanced matching in your blocklist or allowlist.
What is RegEx?
RegEx (or regexp) is short for Regular Expressions (or sometimes known as Rational Expressions). It is a special sequence of characters used to define a search pattern. FocusMe can use RegEx to match specific keywords and/or set of characters to fine-tune your blocklist/allowlist.
If you want to learn more about Regular Expressions, you can read more here:
https://en.wikipedia.org/wiki/Regular_expression
http://perldoc.perl.org/perlre.html
http://perldoc.perl.org/perlretut.html
All RegEx entries should be added using the custom tab when you add targets. Be sure to tick the RegEx checkbox after adding it.
RegEx Examples
You can visit https://regex101.com/ to test out these examples and see what they mean.
Match any Google domain
^.*google.*$
Match Google Image searches
tbm=isch
Note: The above example actually works even if the RegEx box is unticked. Just make sure the type is set to “URL”:
Match example.com but not anotherexample.com
^example\.com.*
Match icloud.com but not other sites such as icloud.com.com/mail/
.*icloud\.com\/?$
Match Google Searches for a particular phrase
^.*google.*q=unicorns.*$
Match google.com but not accounts.google.com or mail.google.com
Supposing you wanted to block all internet but allow only google searches (not allow gmail), then you could put this rule in your allowlist to match google.com but not accounts.google.com or mail.google.com
^(?!.*(accounts\.google\.com|mail\.google\.com)).*google\.com
Match 3 words any order, case insensitive
The example words are community, videos & vimeo
^(?i)(?=.*\bcommunity\b)(?=.*\bvideos\b)(?=.*\bvimeo\b).*$
Match Any Locally Opened Files
This rule when used with URL will match any locally opened file e.g. C:\Documents\example.html
^.:/.*$
Match any word
(?i)\b(some|rude|words)\b
Using \b and \b will block the whole keywords but not if they form part of another word.
Including (?i) makes the whole expression case insensitive.
Please visit https://regex101.com/ to test out these examples and see what they mean. You can also read about what the special characters do:
Need more help with Regular Expressions? There are tons of articles and videos about it online.