preg_match_all() equivalent in Java?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
killElmo
Forum Newbie
Posts: 2
Joined: Fri Feb 20, 2004 11:08 am

preg_match_all() equivalent in Java?

Post 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.
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

don't u think you should post taht in a Java forum and not a PHP one?
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post 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
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post 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
killElmo
Forum Newbie
Posts: 2
Joined: Fri Feb 20, 2004 11:08 am

Post by killElmo »

Thanks Illusionist for responding!! Java is so much more confusing, I'll just stick with Php.
Post Reply