Excerpt |
---|
TRegEx is a useful class for regular expression. You can define a instance with a regular expression, and match the case by TMatch. |
Following is a example to search XML tag by TRegEx and TMatch
Code Block |
---|
|
uses System.RegularExpressions
.
.
.
function getXMLTagValue(source, tag:string):string;
var
mRegExp: TRegEx;
match: TMatch;
begin
mRegExp := TRegEx.Create( '<' + tag + '>(.*)</' + tag + '>', [roIgnoreCase,roMultiline]);
match := mRegExp.Match( source);
if match.Success then
begin
Result := match.Groups.Item[1].Value;
end else begin
Result := '';
end;
end; |