AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
# C.80 PropertyRegexTask Performs regular expression operations on an subject string, and sets the results to a property. There are two different operations that can be performed: - Replace - The matched regular expression is replaced with a substitution pattern - Match - Groupings within the regular expression are matched via a selection expression. Table C.109:聽Attributes NameTypeDescriptionDefaultRequired`property``String`The name of the property to set.n/aYes`override``Boolean`If the property is already set, should we change it's value. Can be `true` or `false`falseNo`subject``String`The subject to be processedn/aYes`pattern``String`The regular expression pattern which is matched in the subject.n/aYes`match``String`A pattern which indicates what match pattern you want in the returned value. This uses the substitution pattern syntax to indicate where to insert groupings created as a result of the regular expression match.n/aYes (unless a replace is specified)`replace``String`A regular expression substitition pattern, which will be used to replace the given regular expression in the subject.n/aYes (unless a match is specified)`casesensitive``Boolean`Should the match be case sensitivetrueNo`limit``Integer`The maximum possible replacements for each pattern in each subject string. Defaults to -1 (no limit).-1No`defaultValue``Integer`The value to set the output property to, if the subject string does not match the specific regular expression.n/aNo C.80.1 Match expressions Expressions are matched in a the same syntax as a regular expression substitution pattern. - $0 indicates the entire property name (default). - $1 indicates the first grouping - $2 indicates the second grouping - etc... C.80.2 Replace It is important to note that when doing a "replace" operation, if the subject string does not match the regular expression, then the property is not set. You can change this behavior by supplying the "defaultValue" attribute. This attribute should contain the value to set the property to in this case. - $0 indicates the entire property name (default). - $1 indicates the first grouping - $2 indicates the second grouping - etc... C.80.3 Example ``` <propertyregex property="pack.name" subject="package.ABC.name" pattern="package\.([^.]*)\.name" match="$1" casesensitive="false" defaultvalue="test1"/> <echo message="${pack.name}"/> <propertyregex property="pack.name" override="true" subject="package.ABC.name" pattern="(package)\.[^.]*\.(name)" replace="$1.DEF.$2" casesensitive="false" defaultvalue="test2"/> <echo message="${pack.name}"/> ```