0

I am trying to use regular expressions, to remove all the content between two strings ...

Suppose this is my content:

    <h2>Misrepresentation of the Facts</h2>
    </script>
    <!-- Articles - Leaderboard 728x90 -->
    </iframe></ins></ins></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>
    <h2>Who Can Commit the Crime</h2>

    I want to remove all content between </script>
    <!-- Articles - Leaderboard 728x90 -->
    </iframe></ins></ins></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>

Any help would be most appreciated.

<\/script>(?:[^<]*(?!.)+<\/script>

<\/script>(?:[^<]*(?!.)+<\/script>
Keith Thompson
  • 254,901
  • 44
  • 429
  • 631
hare ram
  • 1
  • 1
  • Please, re-format your question so that it would be visible where's code and where's the text. Thanks. – JohnyL Jun 25 '19 at 20:01
  • You need more information about the construction of these files to be able to answer your question correctly. If your code contains more – Slawomir Dziuba Jun 25 '19 at 22:00
  • Remove all invisible content `<(?:(script|style|object|embed|applet|noframes|noscript|noembed)(?:\s+(?>"[\S\s]*?"|'[\S\s]*?'|(?:(?!/>)[^>])?)+)?\s*>)[\S\s]*?\1\s*>` –  Jun 25 '19 at 23:59
  • I've edited your title, but the body of your question is still inconsistent about ``. It makes sense to want to delete everything starting with ``. Is that what you meant? – Keith Thompson Jun 26 '19 at 01:58
  • Are you able to assume that the `` tags never nest, and that they never appear in comments or string literals (where they presumably would be ignored)? If not, then [this famous answer](https://stackoverflow.com/a/1732454/827263) has some things to say about parsing HTML with regular expressions. – Keith Thompson Jun 26 '19 at 01:59

1 Answers1

0

I'm just guessing that these expressions being replaced by an empty string might work:

<\/script>[\s\S]*?<\/script>
<\/script>[\d\D]*?<\/script>
<\/script>[\w\W]*?<\/script>

Please see the demo here.

Escaping is just for demoing, and can be removed.

Emma
  • 27,428
  • 11
  • 44
  • 69
  • " – hare ram Jun 26 '19 at 03:52
  • Misrepresentation of the Facts

    Who Can Commit the Crime

    The above all text i want to remove all text between ... i only need

    Misrepresentation of the Facts

    Who Can Commit the Crime

    – hare ram Jun 26 '19 at 04:03
  • yes almost but my text is too long and not selected all items "

    Misrepresentation of the Facts

    Mortgage fraud .

    Who Can Commit the Crime

    While the general person that commits mortgageg, th

    Committing Mortgage Fraud

    Those acting ent laws.

    Criminal Defense for Mortgage Fraud

    When facing charges for mortgage frau "
    – hare ram Jun 26 '19 at 04:13
  • i want to remove all text which come in between the text " " alll i want remove – hare ram Jun 26 '19 at 04:16
  • 1
    oo Great finally working this which i want to remove thanks a lot bro i tried since yesterday.I am using ubot tools for scraping data and remove add from that scraped data. – hare ram Jun 26 '19 at 04:23