Good day. Help someone who knows how to make up the right expression, I can't figure them out at all.
I work with jsoup , through it I get the html-code of one of the required blocks:
<!--Ad Injection:top--> <div style="margin-bottom:10px;"> <center> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- MySite.ru Adaptive 1 --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-6747406633235216" data-ad-slot="7606784485" data-ad-format="auto"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </center> </div> <div> Моя подруга пообещала подарить своей дочке новый iPad за то, что она перейдет из шестого класса в седьмой. </div> <div> Мне в детстве родители обещали дать по шее, если не перейду! </div> <div class="addtoany_share_save_container addtoany_content_bottom"> <div class="a2a_kit a2a_kit_size_32 addtoany_list a2a_target" id="wpa2a_1"> <a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.mysite.ru%2Farchives%2F45450&linkname=%D0%90%D0%BD%D0%B5%D0%BA%D0%B4%D0%BE%D1%82%20%D0%BE%D1%82" title="Facebook" rel="nofollow" target="_blank"></a> <a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.mysite.ru%2Farchives%2F45450&linkname=%D0%90%D0%BD%D0%B5%D0%BA%D0%B4%D0%BE%D1%82%20%D0%BE%D1%82" title="Twitter" rel="nofollow" target="_blank"></a> <a class="a2a_button_vk" href="http://www.addtoany.com/add_to/vk?linkurl=http%3A%2F%2Fwww.mysite.ru%2Farchives%2F45450&linkname=%D0%90%D0%BD%D0%B5%D0%BA%D0%B4%D0%BE%D1%82%20%D0%BE%D1%82" title="VK" rel="nofollow" target="_blank"></a> <a class="a2a_button_odnoklassniki" href="http://www.addtoany.com/add_to/odnoklassniki?linkurl=http%3A%2F%2Fwww.mysite.ru%2Farchives%2F45450&linkname=%D0%90%D0%BD%D0%B5%D0%BA%D0%B4%D0%BE%D1%82%20%D0%BE%D1%82" title="Odnoklassniki" rel="nofollow" target="_blank"></a> <a class="a2a_button_google_plus" href="http://www.addtoany.com/add_to/google_plus?linkurl=http%3A%2F%2Fwww.mysite.ru%2Farchives%2F45450&linkname=%D0%90%D0%BD%D0%B5%D0%BA%D0%B4%D0%BE%D1%82%20%D0%BE%D1%82" title="Google+" rel="nofollow" target="_blank"></a> <a class="a2a_dd addtoany_share_save" href="https://www.addtoany.com/share"></a> <script type="text/javascript"><!-- if(wpa2a)wpa2a.script_load(); //--></script> </div> </div> I use the replaceAll method to replaceAll lines and the regular method I found on the Internet (in this example <br> there isn’t, but there are on other pages of the parson site:
.replaceAll("<br>", "\n").replaceAll("\\<[^>]*>", "")
I end up with this:
// граница (adsbygoogle = window.adsbygoogle || []).push({}); Моя подруга пообещала подарить своей дочке новый iPad за то, что она перейдет из шестого класса в седьмой. Мне в детстве родители обещали дать по шее, если не перейду! // граница Please tell me how to fix the regular schedule to bring the text to a sensible form: remove empty lines, spaces, in the example is not visible, but each empty line contains several spaces, apparently depending on how many tags were on it and screw cleaning to it (adsbygoogle = window.adsbygoogle || []).push({});
Required to pull the text:
Моя подруга пообещала подарить своей дочке новый iPad за то, что она перейдет из шестого класса в седьмой. Мне в детстве родители обещали дать по шее, если не перейду!
String.replaceAll("\\s*?\\r?\\n\\s*?(?=\\r\\n|\\n)", ""). - post_zeew(adsbygoogle = window.adsbygoogle || []).push({});? It can somehow be possible to create a regular schedule for deleting everything between the specified blocks, for example, like this: between(and);? - PolluxjSoup. - post_zeew 7:38 pm