You are viewing a plain text version of this content. The canonical link for it is here.
Posted to regexp-user@jakarta.apache.org by "PISOLKAR,ASHISH (HP-Roseville,ex1)" <as...@hp.com> on 2003/09/16 02:50:24 UTC
regexp RE.subst() issue
Hello,
I am using the RE.subst method.Here is the code on one of my JSP pages.this
is very similar to the example in the docs of the RE
<%
RE r = new RE("( http://[\\.\\w\\-\\?/~_@ <http://[///w//-//?/~_@&=%>
&=%]+)");
String toSubsWith="<a href=\"$0\">$0</a>";
String tempBefStr=r.subst(strDescription,toSubsWith);
%>
strDescription has in it http://something <http://something/> .WHat is
happening is it is finding the http: but while substituting it is
substituting the $0 instead of the whole match.
For example if strDescription =Welcome to http:/www.yahoo.com isnt it great
The string getting returned is "Welcome to $0 isnt it great"
I have tried using
String toSubsWith="<a href=\"$&\">$&</a>";
but that dint help.Am I missing something?I am using the
jakarta-regexp-1.3.jar
Thanks AP