Home › JavaScript Tutorial › JS RegExp
JS RegExp
Pattern matching.
A pattern like /[a-z]+@[a-z]+/i works with test, match and replace. Flags: g global, i ignore case.
Example code
<pre id='o'></pre>
<script>
const t='Call 98765 or 12345';
o.textContent=[/[0-9]{5}/.test(t),t.match(/[0-9]{5}/g),t.replace(/[0-9]/g,'#'),/hello/i.test('HELLO')].join('\n');
</script>