In last post, Using HTML Parser Jsoup and Regular Expression to Extract Text between Tow TagsI introduced how to use Jsoup and Regular Expression to extract content between two anchor tags. 

My current regex is: 
Writing efficient Regex is complicated, luckily there are several tools that can help us.

The best one is RegexBuddy. The trail RegexBuddyCookbook.exe is fully functional for seven days of actual use. 

Select Regex language(Java, Python, etc), type regex string, paste content in test panel, then click “Debug till end” from Debug drop-dwon buttons. In the debug panel, it will list all steps the regex engine executes.

document.write("(adsbygoogle = window.adsbygoogle || []).push({});”)

In the Create panel, RegexBuddy will give the explanation of the regex. Select one token then click “Explain Token”. We can also export the regex string and the explanation.

In the convert panel, we can convert between different regex languages.

Other Tools
We can use regexplanet to covert regex string to a java string. 

Regex Optimization Tips
Use the any (dot) operator sparingly.
Use the non-capturing group (?:pattern) if possible.
Use the atomic group (or non-backtracking subexpression) when applicable (?>pattern).
Alternation: The order of alternation counts, so place the more common options in the front so they can be matched faster.

Optimizing regular expressions in Java

via Blogger http://ift.tt/1i8ZnvM