Reputation: 9
I want to match string with value "vikas" which is half in some tag(any tag dont use span only) and half outside of it.
e.g:
<span class="can-map"><span id="1" class="can-map">vikas</span></span>
<span id="2" class="can-map">vi<span>kas</span></span>
by using this regex: /vikas/gi
I am getting value inside id=1 but not from id=2. Kindly help.
Upvotes: 0
Views: 46
Reputation: 34
function getVikas() {
const reg = /vikas/gi;
var one = document.getElementById('1');
var two = document.getElementById('2');
console.log(reg.test(two.innerText)); // true
}
getVikas();
<span class="can-map"><span id="1" class="can-map">vikas</span></span>
<span id="2" class="can-map">vi<span>kas</span></span>
Try something like this
Upvotes: 1