Search code examples
javascriptjquerystringline-breaks

How To Remove All Text Before a Specific Value in a String


I have the following string, "blahblah
hellothere", that I would like to be shortened to "hellothere" using JavaScript and/or JQuery.

I have tried using the following code:

var titletext123 = "blahblah<br>hellothere"
        var injuryt3xt = titletext123.substring(titletext123.indexOf("<br>") +1);

Which only returns "br>hellothere".

Does anyone have any code which will get rid of the
and all text before it?

Thank you very much. All of your help is appreciated!


Solution

  • Make it

    var titletext123 = "blahblah<br>hellothere" var injuryt3xt = titletext123.substring(titletext123.indexOf("<br>") + 4);
    

    So it is +4. Which accounts for all the characters in <br>.