B
brainstorm
Hi, I'm using Borland Delphi .NET 2005 and I've got a problem using
Regular Expressions.
But the RegExOptions do not work properly.
My Replace - function looks like:
function TWebForm1.RegExpTags(InputString, Pattern, StringReplacement:
String): String;
var
rx: RegEx;
begin
rx:=RegEx.Create(Pattern, &RegExOptions.IgnoreCase OR
&RegExOptions.Multiline);
RegExpTags:=rx.Replace(InputString, Pattern, StringReplacement);
rx.Free;
end;
My regular expression is:
\[img\]((http|ftp|https|ftps)://)([^
\?&=\#\"\n\r\t<]*?(\.(jpg|jpeg|gif|png)))\[/img\]
I want to use it to replace sub strings like
So, I call this function as follows:
StrPattern:='\[img\]((http|ftp|https|ftps)://)([^
\?&=\#\"\n\r\t<]*?(\.(jpg|jpeg|gif|png)))\[/img\]';
StrReplace:='<img src="$1$3" border="0">';
OutputString:=RegExpTags(SomeText, StrPattern, StrReplace);
Response.Write(OutputString);
This partly works.
....
...
is being replaced by
<img src="http://www.test.com/test.jpg" border="0">
But Neither
....
...
is not being replaced
Nor
....
...
So why does the RegEx Function not replace the sub strings although the
IgnoreCase property is being set? Do I assign the property not
correctly? Or is there any possibility to set the IgnoreCase properties
in the Regular Expression itself like in Perl with /i/s or #is ? I
already tried it that way but without success.
I hope that someone can help me.
Regular Expressions.
But the RegExOptions do not work properly.
My Replace - function looks like:
function TWebForm1.RegExpTags(InputString, Pattern, StringReplacement:
String): String;
var
rx: RegEx;
begin
rx:=RegEx.Create(Pattern, &RegExOptions.IgnoreCase OR
&RegExOptions.Multiline);
RegExpTags:=rx.Replace(InputString, Pattern, StringReplacement);
rx.Free;
end;
My regular expression is:
\[img\]((http|ftp|https|ftps)://)([^
\?&=\#\"\n\r\t<]*?(\.(jpg|jpeg|gif|png)))\[/img\]
I want to use it to replace sub strings like
So, I call this function as follows:
StrPattern:='\[img\]((http|ftp|https|ftps)://)([^
\?&=\#\"\n\r\t<]*?(\.(jpg|jpeg|gif|png)))\[/img\]';
StrReplace:='<img src="$1$3" border="0">';
OutputString:=RegExpTags(SomeText, StrPattern, StrReplace);
Response.Write(OutputString);
This partly works.
....
is being replaced by
<img src="http://www.test.com/test.jpg" border="0">
But Neither
....
is not being replaced
Nor
....
So why does the RegEx Function not replace the sub strings although the
IgnoreCase property is being set? Do I assign the property not
correctly? Or is there any possibility to set the IgnoreCase properties
in the Regular Expression itself like in Perl with /i/s or #is ? I
already tried it that way but without success.
I hope that someone can help me.