Page 1 of 1

preg_match_all() equivalent in Java?

Posted: Fri Feb 20, 2004 11:08 am
by killElmo
Is there a preg_match_all equivalent in Java? I want to find webaddress in link <a href="(.*?)"></a>.
I usually do my programming in Php and sometimes the preg_match_all takes quite some time. I want to do a Java equivalent to see which language will process faster.

Posted: Fri Feb 20, 2004 5:02 pm
by Illusionist
don't u think you should post taht in a Java forum and not a PHP one?

Posted: Fri Feb 20, 2004 5:03 pm
by Illusionist
well, i atually did a little research for you, and i found a couple links, just google for Java perl regualr expressions... check ths out, this may work:

Code: Select all

String text = "<a href="ad1">sdqs</a><a href="ad2">sds</a><a href=ad3>qs</a>";
Pattern pattern = Pattern.compile("(?i)href="?(.*?)"?>");
Matcher matcher = pattern.matcher(text);

while (matcher.find())
&#123;
   System.out.println(matcher.group(1));
&#125;
found here

Posted: Fri Feb 20, 2004 5:05 pm
by d3ad1ysp0rk
why would it matter which language does it faster? Java is application based and PHP and web based.

and even if you were using a web applet, PHP is always faster because applets need loading time which can often be excesse of 5 seconds, whereas 99% of PHP scripts run in < 1 second

Posted: Sat Feb 21, 2004 2:40 pm
by killElmo
Thanks Illusionist for responding!! Java is so much more confusing, I'll just stick with Php.