How can I match text along with formattings of a text in a web page

Suppose in MS Word, my text is like below

hello how are you

  • Detect Google Earth is installed in a web page on Internet Explorer
  • Get JavaScript JSON code in IE using jQuery
  • Update Panel AsyncPostback Trigger not working in IE
  • IE: Undocumented “cache” attribute defined for input elements?
  • Access is Denied on IE11 in AngularJS
  • Is “Page Source” BEFORE or AFTER JavaScript has been rendered?
  • In Web page I have used same text like below

     <b>hello</b> how are <i>you</i>...
    

    How can i match the string in a web page along with web page.. Currently I am taking the data from copied text from word using

      Clipboard() Object.
    

    and Matching text using

      createTextRange();
    

    I am pretty sure that this will match the text in a web page. But I am trying to match the text along with formattings..

    In the above scenario If i search for “hello how are you” and the bold or italic is not given to any of “how” or “you” that should not match the string.

    Please suggest me ways to achieve this. When reading from Clipboard(), How can read along with formattings…

  • Has anyone got processing.js working in IE?
  • What causes the error “Can't execute code from a freed script”
  • Prevent onclick event in IE8
  • Inserting text into an editable IFRAME at the caret position (IE)
  • Is there a way that I can detect if Firefox will open a particular URL in an IE tab?
  • Prevent default key handling in IE9
  • One Solution collect form web for “How can I match text along with formattings of a text in a web page”

    You’re going to have to use regular expressions. And it’s going to be VERY complex. Basically, regular expressions allow you to say things like:

    Find me all instances where “hello” occurs between a “<b>” and a “</b>” and is followed by ” how are ” and then “you” within an “<i>” and “</i>”.

    The plus of using regular expressions is also that you can write a simple/short regular expression which will allow for matching a bolded “hello” with:

    //All of these are valid code and a bolded hello in HTML
    <b>hello</b>
    <b >hello</b >
    <B>hello</B>
    

    I’d recommend starting here:

    http://www.regular-expressions.info/