I have HTML like so:
<br>
For the application these are [a bunch of random characters that need to be removed]).
<br?
<br>
I need to use Javascript/JQuery (probably a regular expression) to remove the HTML starting with:
For the application these are
and ending with:
).
<br>
<br>
Everything in between must go too.
As far as I understood, this should work for you. Demo url: http://regexr.com/3gioj
$(your_element).replace(/For the application these are .+?(\)\.)/g,"")
If the words and characters are accurate and 100% exact in all scenarios, then easily:
var sentence = "For the application these are foofoofoo!!!)"
sentence = sentence.replace(sentence.split("For the application these are ")[1].split(")")[0], "");
console.log(sentence);
//output: For the application these are )
Don't even need RegEx. Then just append sentence to wherever u want to
Here's a snippet to remove everything from and including For
to ).
using regex.
document.body.innerHTML = document.body.innerHTML.replace(/For(.*?)\\)\\./,''); console.log(document.body.innerHTML);
<br> For the application these are (sdi12ni3jo45n). <br> <br>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.