kulfi kulfi - 1 year ago 69
HTML Question

Get text wrapped into <b> and separated by <br> using jquery

I receive the output from services in html string format as follow :

"<html>↵<h1>↵Example : ↵<br>Explanation↵</h1>↵<hr>↵<b>key1 : ABCD <br>key2 : 2016-10-18-18-38-29<br>Output: /acddfd/example</b>↵</html>↵"

Then I parse the html to get tag
as follows:

var input="<html>↵<head>↵<h1>↵Example : ↵<br>Explanation↵</h1>↵<hr>↵<b>key1 : ABCD <br>key2 : 2016-10-18-18-38-29<br>Output: /acddfd/example</b>↵</html>↵";
var parsed= $.parseHTML(input);

Then I find parsed as an array of html tags:

<b>key1 : ABCD <br>Date : 2016-10-18-18-38-29<br>Output: /acddfd/example</b>

Now I need to get the value of Date for further operation.

Can anyone help me to get the value of Date (e.g.
) using js/jquery?

Answer Source

Use this regex

var Date= str.match(/(\d{4})-(\d{2})-(\d{2})-(\d{2})-(\d{2})-(\d{2})/g);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download