0
Having issue getting the inner Text of a tag with regex..
I am trying to get the innertext with regex but it also selects text within tag like class heading etc.. i just want to get the "Take your business strategy to the next level and automatize your marketing tasks to save time for product development." <p class="p-heading">Take your business strategy to the next level and automatize your marketing tasks to save time for product development.</p>
2 Réponses
+ 1
Basic way would be this:
let text = '<p class="p-heading">Take your business strategy to the next level and automatize your marketing tasks to save time for product development.</p>';
let string = text.match(/>(.*?)</)[1]
console.log(string) // Take your business strategy to the next level and automatize your marketing tasks to save time for product development.
If you have a more complicated set-up (with nested element for example), it would require more work.
+ 3
If you can link that part of code section where you are trying to get text using regex then only someone might know why it is so ,and can provide you any help