Package lib :: Module regex
[hide private]
[frames] | no frames]

Module regex

source code

Module implementing relax regular expression.

Functions [hide private]
bool
search(pattern, id)
Determine if id matches the pattern, or vice versa, allowing for regular expressions.
source code
Variables [hide private]
  __package__ = 'lib'

Imports: re


Function Details [hide private]

search(pattern, id)

source code 

Determine if id matches the pattern, or vice versa, allowing for regular expressions.

This method converts from relax's RE syntax to that of the re python module.

The changes include:

  1. All '*' to '.*'.
  2. The identifier is bracketed, '^' is added to the start and '$' to the end.

After conversion of both the string and patterns, the comparison is then performed both ways from the converted string matching the original string (using re.search()).

Parameters:
  • pattern (anything) - The pattern to match the string to. This can be a list of patterns. All elements will be converted to strings, so the pattern or list can consist of anything.
  • id (None, str, or number) - The identification object.
Returns: bool
True if there is a match, False otherwise.