'Sets regex to use for searching for date in log line.
Parameters
regex : str
The regex the template will use for searching for a date.
wordBegin : bool
Defines whether the regex should be modified to search at beginning of a
word, by adding special boundary r\'(?=^||\W)\' to start of regex.
Can be disabled with specifying of ** at front of regex.
Default True.
wordEnd : bool
Defines whether the regex should be modified to search at end of a word,
by adding special boundary r\'(?=|\W|$)\' to end of regex.
Can be disabled with specifying of ** at end of regex.
Default True.
Raises
re.error
If regular expression fails to compile'

def setRegex(self, regex, wordBegin=True, wordEnd=True):

    regex = regex.strip()
    boundBegin = (wordBegin and (not RE_NO_WRD_BOUND_BEG.search(regex)))
    boundEnd = (wordEnd and (not RE_NO_WRD_BOUND_END.search(regex)))
    if (not RE_GROUPED.search(regex)):
        regex = RE_GROUP[0].sub(RE_GROUP[1], regex)
    self.flags = 0
    if boundBegin:
        self.flags |= (DateTemplate.WORD_BEGIN if (wordBegin != 'start') else DateTemplate.LINE_BEGIN)
        if (wordBegin != 'start'):
            regex = ('(?:^|\\b|\\W)' + regex)
        else:
            regex = ('^(?:\\W{0,2})?' + regex)
            if (not self.name.startswith('{^LN-BEG}')):
                self.name = ('{^LN-BEG}' + self.name)
    if boundEnd:
        self.flags |= DateTemplate.WORD_END
        regex += '(?=\\b|\\W|$)'
    if RE_LINE_BOUND_BEG.search(regex):
        self.flags |= DateTemplate.LINE_BEGIN
    if RE_LINE_BOUND_END.search(regex):
        self.flags |= DateTemplate.LINE_END
    regex = RE_DEL_WRD_BOUNDS[0].sub(RE_DEL_WRD_BOUNDS[1], regex)
    self._regex = regex
    logSys.debug('        constructed    regex    %s', regex)
    self._cRegex = None
