google.cloud.forseti.common.util.regular_exp module

Regex utility module.

escape_and_globify(pattern_string)[source]

Given a pattern string with a glob, create actual regex pattern.

To require > 0 length glob, change the “*” to “.+”. This is to handle strings like “*@company.com”. (The actual regex would probably be “.*@company.com”, except that we don’t want to match zero-length usernames before the “@”.)

Special case the pattern ‘*’ to match 0 or more characters.

Parameters:pattern_string (str) – The pattern string of which to make a regex.
Returns:
The pattern string, escaped except for the “*”, which is
transformed into “.+” (match on one or more characters).
Return type:str