I have the following code:
searchSt = “Test”, searchEd = ” in”;
var html = body.clone()
.children()
.remove()
.end()
.text();
alert(searchSt + "|" + searchEd);
var patt = searchSt + "(.*)" + searchEd;
var result = html.match(patt);
alert(result[0]); //returns null
This returns null although I am sure the words are there:
html:
Hello World
Test Write SomeThing here is Words do it. hit in me
What is wrong?
If you are using JQuery the code should be the following:
Make sure that script is placed below the body tag. If it’s above than the body tag can’t be found. And also I changed the way how to get body $(‘body’).
There is no problem with regex