Example Code Copy & paste to the above left text area, and check 'eval'. // Regular expression editor var pat = /.+/; "abc\ndef".match(pat); // Selection var textarea = document.getElementById("code"); textarea.selectionStart + ":" + textarea.selectionEnd;