/

HTML / CSS / JavaScript Tutorial

JavaScript regular expressions: “\f” character

[this page | pdf | back links]

A JavaScript regular expression takes the form: /pattern/modifiers

 

The character sequence \f in a regular expression has a special meaning, namely a form feed.

 

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(12);
document.getElementById("Example").innerHTML =
  'var str = "Hello WORLD" + String.fromCharCode(12);' + '<br>' +
  'var x = str.replace(/\\f/gi,"*");';
document.getElementById("Result").innerHTML
  = str.replace(/\f/gi,"*");
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | JavaScript Regular Expressions


Desktop view | Switch to Mobile