Regular Expressions IgnoreCase

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.
....
test.jpg
...
is being replaced by
<img src="http://www.test.com/test.jpg" border="0">

But Neither
....
test.jpg
...
is not being replaced

Nor
....
test.JPG
...


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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top