The \f metacharacter matches a form feed (FF) control character—an invisible code historically used for page breaks on printers. Modern web apps rarely create form feeds, but regex helps you detect and clean them in legacy files and exports.
01
FF char
\f
02
ASCII 12
U+000C
03
Whitespace
In \s
04
vs \n
Different
05
Split
Sections
06
Clean
replace
Fundamentals
Introduction
Control characters are invisible codes embedded in strings. You already know \n for new lines and \r for carriage return. Form feed (\f) is another—it once told printers to start a new page.
You will not see form feeds in everyday user input, but they can appear in old documents, mainframe exports, and some PDF-to-text conversions. Regex lets you find and normalize them.
Concept
Understanding the \f Metacharacter
\f matches exactly one form feed character. Like other control codes, it is not visible when rendered but occupies one position in the string.
Use test() to check for presence, match() to count breaks, and replace() to convert form feeds into display-friendly spacing.
Foundation
📝 Syntax
JavaScript
/\f/ // single form feed
/\f+/ // one or more form feeds
/\f/g // all form feeds (global)
/\s/ // any whitespace (includes \f)
/[\f\n\r]+/ // form feed or line breaks
Common patterns
/\f/g — find every form feed in a document.
str.split(/\f/) — split into page-like sections.
str.replace(/\f/g, "\n") — normalize to newlines.
/[^\f]+/g — match text runs between form feeds.
Cheat Sheet
⚡ Quick Reference
Goal
Pattern / Code
Match form feed
\f
String literal FF
"\f"
Split on page breaks
str.split(/\f/)
Replace with newline
str.replace(/\f/g, "\n")
Any whitespace
\s (includes \f)
Char code check
charCodeAt(i) === 12
Compare
📋 \f vs \n vs \r vs \s
Four related whitespace and control-character patterns.
Form feed
\f
Page break
Line feed
\n
New line
Carriage return
\r
CR char
Whitespace
\s
All incl. \f
Hands-On
Examples Gallery
Open DevTools Console (F12) or use Try-it links. Examples cover detection, splitting, replacement, whitespace classes, and cleanup.
📚 Getting Started
Detect form feed characters in a string.
Example 1 — Test for Form Feed
Check whether text contains a form feed control character.
Char code 12 identifies form feed: "\f".charCodeAt(0) === 12.
For general whitespace cleanup, /\s+/g also removes form feeds.
Modern apps rarely emit \f; treat it as a legacy-format signal.
Compatibility
Browser & Runtime Support
The \f form-feed escape is part of core JavaScript regular expression syntax.
✓ Baseline · ES3+
RegExp \f
Supported in every browser and Node.js version. Form feed matching behaves consistently across all JavaScript runtimes.
99%Universal syntax
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
\fExcellent
Bottom line: Safe everywhere. Use \f when cleaning or parsing legacy text with page-break characters.
Wrap Up
Conclusion
The \f metacharacter matches form feed control characters—legacy page-break markers that still appear in some imported documents. Detect them with /\f/, split sections with split, and normalize with replace.
Remember that form feed is whitespace in \s but distinct from \n and \r. Next, learn the \n newline metacharacter.
Expect form feeds to render as visible line breaks in HTML
Assume modern user input contains form feeds
Forget the global flag when replacing all occurrences
Mix up string "\\f" and regex /\f/ escaping
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about RegExp \f
Handle form feed page-break characters in JavaScript.
5
Core concepts
📄01
Form feed
\f
Syntax
🔢02
ASCII 12
U+000C
Code
✂03
Split
Sections
Pattern
🛠04
In \s
Whitespace
Compare
🔄05
Replace
→ \n
Clean
❓ Frequently Asked Questions
\f matches the form feed control character (FF, Unicode U+000C, ASCII 12). It was originally used to advance to the next page on printers and still appears in some legacy text files.
No. \f is form feed (page break). \n is line feed (new line). They are different control characters, though both can act as whitespace separators in text processing.
Yes. Form feed is included in the \s whitespace class along with space, tab, newline, carriage return, and other Unicode space separators.
Use an escape in a string literal: "page1\fpage2". In regex literals write /\f/; in new RegExp() strings use "\\f".
Mostly when parsing or cleaning legacy documents, printer-formatted data, or exported files that embed form feed characters as page or section breaks.
The \f escape is core regex syntax since ES3. It works in every browser and Node.js version.
Did you know?
In the ASCII control-character table, form feed (12) sits between vertical tab (11) and carriage return (13). Together with line feed (10), these codes shaped early text file formats long before the web existed.