var str = ' www.stackoverflow.com <a href="http://www.somesite.com">somesite</a> www.othersite.org ',
rex = /(<a href=")?(?:https?:\/\/)?(?:\w+\.)+\w+/g;
str = str.replace( rex, function ( $0, $1 ) {
return $1 ? $0 : '<a href="' + $0 + '">' + $0 + '</a>';
});
我想在JAVA / JSP中实现这个逻辑,任何人都可以帮助我PLZ