Skip to content

Instantly share code, notes, and snippets.

@JFriel
Created May 30, 2015 20:48
Show Gist options
  • Save JFriel/413d8f222f844adaee02 to your computer and use it in GitHub Desktop.
Save JFriel/413d8f222f844adaee02 to your computer and use it in GitHub Desktop.
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)
}
}
}
@PeterCarragher
Copy link

does line 13 have a rather annoying typo?
div.adressscroll, should that be doc.addressscroll?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment