JavaScript regular expressions: “\t”
character
[this page | pdf | back links]
A JavaScript
regular expression takes the form: /pattern/modifiers
The character sequence \t
in a regular expression has a special meaning, namely a (horizontal) tab.
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
table,th,tr,td {border: 1px solid black; border-collapse: collapse;}
</style>
</head>
<body>
<table>
<tr>
<th>Example</th>
<th>Resulting value of <code>x</code></th>
</tr>
<tr>
<td><code id="Example"></code></td>
<td><code id="Result"></code></td>
</tr>
</table>
<script>
var str = "Hello WORLD" + String.fromCharCode(9);
document.getElementById("Example").innerHTML =
'var str = "Hello WORLD" + String.fromCharCode(9);<br>' +
'var x = str.replace(/\\t/gi,"*");';
document.getElementById("Result").innerHTML
= str.replace(/\t/gi,"*");
</script>
</body>
</html>
|
NAVIGATION LINKS
Contents | Prev | Next | JavaScript Regular Expressions