\f matches the form feed control character (U+000C, ASCII 12). It once meant “next page” on printers and still shows up as a page or section break in some legacy text files.
Remember
\f → form feed (U+000C)
\n → newline (different character)
\r → carriage return (different character)
\s → any whitespace, including \f
"page1\fpage2" → string with a form feed
/\f/.test(...) → true when FF is present
split(/\f/) → break on page markers
Treat form feed as a specific control character — detect it, split on it, or replace it.
Build or import text that may contain form feeds (string escape: "\f").
Use /\f/ with test, match, split, or replace.
Add the g flag when you need every form feed, not just the first.
Do not confuse \f with \n — they are different characters.
Piece
Required?
Role
\f in the pattern
Yes
Match the form feed character
String escape "\f"
For demos / fixtures
Insert FF into a JavaScript string
g flag
Optional
Find or replace every form feed
\s
Optional
Broader whitespace class that includes \f
Pseudocode
Pseudocode
pattern has "\f"
read next character ch from the string
if ch.codePoint === 0x000C: // form feed
accept match
else:
fail this path
common actions:
test(str) → true/false
split(str) → parts between FF
replace(str) → swap FF for space or "\n"
Reference
Cheat Sheet
Keep these facts handy when cleaning control characters.
Topic
Detail
Character
Form feed — U+000C (ASCII 12)
Regex / string
/\f/ · "\f" · new RegExp("\\f")
vs newline
\f ≠ \n ≠ \r
Whitespace
Included in \s
Split pages
doc.split(/\f/)
Normalize
str.replace(/\f/g, "\n") or " "
Standard
ES3+ (universal)
Try it
Live Preview
Run common \f operations on sample text that contains a form feed.
Browser demo of the RegExp \f form feed escape — same ideas as the examples below.
Result
text = "Page A\fPage B"
/\f/.test(text)
→ true
/* form feed (U+000C) is present */
Code
JavaScript Examples
Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.
Example 1 — Detect Form Feed
Check whether text contains a form feed — and confirm it is not a newline.
Use a global pattern./\f/g finds every form feed, not only the first.
Swap for newlines. Each FF becomes "\n\n" so page breaks show as blank lines.
Inspect safely.JSON.stringify makes the escape sequences visible in the console.
Other targets. You can also replace with a space or "" to strip page breaks.
Edge Cases & Pitfalls
Check these before relying on \f in real projects.
trap
\f is not \n
Form feed and newline are different characters. Patterns for one do not match the other.
escape
new RegExp needs double escaping
Write new RegExp("\\f"). A single "\f" string already becomes the character before the constructor sees it — for a pattern string you need "\\f".
whitespace
\s also matches form feed
Broad whitespace cleanup with /\s/g removes \f too. Use /\f/ when you mean only form feed.
display
Often invisible in the UI
Browsers may not show a visible mark for FF. Use charCodeAt, JSON.stringify, or replace with a visible marker while debugging.
Compatibility
Browser & Runtime Support
The \f form feed escape is core regex syntax (ES3+) and works everywhere JavaScript runs.
✓ Baseline · ES3+
RegExp \f
Supported in every modern and legacy browser, plus all Node.js versions. No polyfill required.
100%Universal support
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 to use in any JavaScript environment. Focus on correctness (escaping, g flag) rather than compatibility.
Analysis
Performance Notes
Approach
Cost
Best for
/\f/.test(str)
O(n)
Quick presence checks
str.split(/\f/)
O(n)
Page / section parsing
str.replace(/\f/g, …)
O(n)
Cleanup and normalization
Matching a single control character is cheap. Prefer /\f/ when you only care about form feed; use \s only when any whitespace should match.
Remember
Key Takeaways
Role:\f matches the form feed control character (U+000C).
Not a newline: use \n / \r for line endings; \f for page breaks.
Common jobs:test, split, and replace on legacy documents.
Whitespace:\s includes \f — choose the tighter pattern when you can.
One line:\f finds form feed page breaks — split or replace them when cleaning legacy text.
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 a regex literal write /\f/; in new RegExp() string patterns 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.