Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String text_to_match= "abcd";
- String allText = "<h1><a></a>abcd</h1>";----return true
- String allText = "<h1 class='ssss'><a></a>abcd</h1>";----return true
- String allText = "<h1 class='ssss'><a>dsdsd</a>abcd</h1>";---return false
- String allText = "<h1 class='ssss'><a></a><span></span>abcd</h1>";----true
- String allText = "<h1 class='ssss'><a></a><span>s</span>abcd</h1>";----false
- String allText = "<h1 class='ssss'><a>ddd</a><any-tag>sss</any-tag>abcd</h1>";---false
- <headertag 1-6> any tag may come but no text in between (text_to_match) </header tag 1-6>
- Pattern p_anchor = Pattern.compile("<h[1-6](?:(?!</h).)*>(\s|( ))*(.*>)"+anchor+"(\s| )*<.*>(\s|( ))*</.*><(?:(?!/h).)*/h[1-6]>");
- Matcher m_anchor = p_anchor.matcher(allText);
Add Comment
Please, Sign In to add comment