Created
May 30, 2015 20:48
-
-
Save JFriel/413d8f222f844adaee02 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.jsoup.Jsoup; | |
public class postcodefinder{ | |
public static void main() { | |
String html = "bfbvfvbrbvb <div id='adressscroll'> G74 4GX</div>";//htmlin | |
Pattern pattern = Pattern.compile("[A-Z]{1,2}[0-9R][0-9A-Z]? [0-9][ABD-HJLNP-UW-Z]{2}"); | |
Document doc = Jsoup.parse(html); | |
Element address = doc.select("div.adressscroll").first(); | |
String divString = address.html(); | |
Matcher matcher = pattern.matcher(davString); | |
if (matcher.find()){ | |
//System.out.println(matcher.group(1)); | |
return matcher.group(1) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
does line 13 have a rather annoying typo?
div.adressscroll, should that be doc.addressscroll?