"Todd A. Jacobs" <[EMAIL PROTECTED]> writes:

> Can one use variable or macro expansion inside a headers regex?

Oddly enough, yes, with a few restrictions.  Here's the regular
expression I use to find a macro name during expansion (self.name is
the name of the macro I'm searching for):

    pattern = r'(?:^|[^_\w])(' + self.name + r')(?:[^_\w]|$)'

In essence, the name must be found preceded by either the beginning of
the line or by any character that is *not* an underscore, an
alphabetic letter (case-insensitive) or a digit.  The character
following the name must not be any of those same characters; if there
is no character (meaning it's the end of the line), that's fine too.

As long as those rules are met, macros will be found and expanded,
even inside regular expression strings.

For variables, because the variable is specially delimited by '${' and
'}' at the beginning and end, respectively, there are no restrictions
on preceding or trailing characters.  Variables will be expanded in
strings and even in the middle of paths, etc.


Tim
_____________________________________________
tmda-users mailing list ([EMAIL PROTECTED])
http://tmda.net/lists/listinfo/tmda-users

Reply via email to