I have a homework I need to present in about a week. The criteria are:
Write a web page with two text areas T1 and T2. The user enters a string into the text area T1 to present a regular expression. Then the user enters some text into the text area T2. Your code should output the text of T2 with highlighted elements corresponding to the matches for the regular expression of T1.
P.S. There is an extra condition to match only the last occurence.
So far I have generated this piece of code :
The problem is that when i click the "Test Match" button nothing happens (and i know that with the given Regular expression it should find a match with the string). I suspect that the function isn't constructing the RegExp object at all. There is probably some issues with the way I address the content of the two textareas. But I cannot find my error. Can someone help? I would really appreciate it.
var testchar = new RegExp(document.m.value);
<p><b> RegExp : </b></p> <textarea id="m" name="T1" cols="30" rows="5" >\bt[a-z]+\b</textarea>
<input type=submit value="Test Match" onClick="match()">