You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oro-user@jakarta.apache.org by Christian Ribeaud <ch...@predict.ch> on 2001/01/25 09:06:22 UTC

url to links

Hi,

I can not get the following code working:

---------------------------- code ------------------------------------------
String hyperlinks = "(ftp://)|(http(s?)://)([:alnum:]|[:punct:])+";
PatternMatcher matcher = new Perl5Matcher();
Pattern pattern = new Perl5Compiler().compile(hyperlinks);
PatternCompiler compiler = new Perl5Compiler();
int limit = Util.SUBSTITUTE_ALL;
int interps = Perl5Substitution.INTERPOLATE_ALL;
String result = Util.substitute(matcher, pattern,
new Perl5Substitution("<a href=\"$1\" target=\"_new\">$1</a>", interps),
body, limit);
---------------------------- code ------------------------------------------

How to specify the whole match in the Perl5Substitution? $0 or \\0 did not work.
I would be very grateful if someone could help me. Since 2 hours, I am trying any variant from this code. Thanks in advance and have a nice day,

christian


Re: url to links

Posted by Takashi Okamoto <to...@rd.nttdata.co.jp>.
> String hyperlinks = "(ftp://)|(http(s?)://)([:alnum:]|[:punct:])+";

ORO doesn't support POSIX style expression like [:foo:].
But some libraries (ex.Jakarta-Regexp) support this expression.
And you can check your expression by following applet:

http://www21.freeweb.ne.jp/computer/torakun/java/regex/regex.html

regards.
--------------------------
Takashi Okamoto