cdub cdub - 1 year ago 88
Javascript Question

Javascript or JQuery to remove certain text and characters between

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.

Answer Source

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>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download