I have a code editor on my site, and after the user runs the code, I want to validate if the code is correct.
For example, if the user writes the following code:
<p>Some text</p>
I want to validate if the code contains a <p>
tag.
What I tried :
if(language == "HTML"){
if (html_code.includes(expected)) {
alert('right!');
}
else {
alert("wrong");
}
}
But it only works if the user types nothing between the <p>
tag.
So how can I find if the code includes certain tags ?
hello world
will return true, but "Hello world" will return false Just trying to check if there's atag for example.
– עילאי אלמלם Jul 12 '20 at 06:04