Page tree
Skip to end of metadata
Go to start of metadata

Filter rules - Regular Expression based


As described in Dynamic Link Manager filter rules, filters can be Regular Expression based to filter on the Caller/Callee object's Name of Full Name. Regular Expressions must be in .NET format as described here. You can use the following "cheat sheet" to get you started:

\b Start at a word boundary.
(\w+) Match one or more word characters. Together, they form a group that can be referred to as \1.
\s Match a white-space character.
\1 Match the substring that is equal to the group named \1.
\b Match a word boundary.
\s* Look for zero or more occurrences of a white-space character.
[-+]? Look for zero or one occurrence of either a positive sign or a negative sign.
([0-9]{0,3}(,[0-9]{3})*(\.[0-9]+)?) The outer parentheses around this expression define it as a capturing group or a subexpression. If a match is found, information about this part of the matching string can be retrieved from the second Group object in the GroupCollection object returned by the Match.Groups property. (The first element in the collection represents the entire match.)
[0-9]{0,3} Look for zero to three occurrences of the decimal digits 0 through 9.
(,[0-9]{3})* Look for zero or more occurrences of a group separator followed by three decimal digits.
\. Look for a single occurrence of the decimal separator.
[0-9]+ Look for one or more decimal digits.
(\.[0-9]+)? Look for zero or one occurrence of the decimal separator followed by at least one decimal digit.
Escaping special characters

Note that certain special characters used in Regular Expressions may need escaping with a back slash (\), for example:

  • - (
  • - )
  • - "

Therefore using the following Regular Expression (see below) in a Dynamic Link Manager filter rule:

<?xml version="1.0" encoding="utf-8"?><dynamicLinksRules xmlns="http://www.castsoftware.com/DlmRulesModel.xsd" >  <rule name="Ruleoutprintln" action="ignore" >  <leftStringFromCode regexp="\t*out.println\(\&quot;&lt;a href"/>  </rule> </dynamicLinksRules>

will match for example:

\t\tout.println("<a href='showDistinctMonster.jsp?MONSTER_ID="lt_monster.getMonsterId()"'>"lt_monster.getStringValue()"</a> <BR/>");
Testing a Regular Expression

You can test your Regular Expression using: http://regexstorm.net/tester

See Also

Dynamic Link Manager filter rules


CAST Website

  • No labels