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.
preg_match_all() equivalent in Java?
Moderator: General Moderators
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
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:
found here
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())
{
System.out.println(matcher.group(1));
}-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA