Considering an arbitrary text I'd like to identify a specific text inside of it. I have been working on a code until now, but it's really hard to me to get some way to solve that.
One important point is that when I get the text the spaces are in some quantity, but after I get other text to compare, that's why I need to don't care about the number of spaces.
Example of the first text:
Here, bla bla bla bla
() => console.log()
end
Example of text to be selected on the second text according to the first text:
() => console.log()
Example of the second text to select the value I want:
Here, bla bla bla bla
() => console. log()
en d
Just remembering some criterias:
- The spaces between the words can vary and the jump lines can be a lot more
- I need to match some letters inside other text with other formate, not matter the spaces or jump lines between them
My code until now:
let firstCharCode = mainText.replace(/ /g,'').indexOf(textToBeSelected.replace(/ /g, ''))
let lastCharCode = firstCharCode + textToBeSelected.replace(/ /g, '').length - 1
let numberOfCharsToSelect = lastCharCode - firstCharCode
for (let i = 0; i < a.length; i++) {
// iterate through them checking where is the chars?
}