Regex Cheatsheet
Every regex token, searchable, with an example of what it matches.
Measure text in UTF-8 bytes, code points, UTF-16 units and graphemes.
The String Byte Counter measures a string four ways at once — UTF-8 bytes, code points, UTF-16 units and graphemes — because using the wrong one of those is a real and common source of bugs.
Four different numbers can all reasonably be called "the length" of a string, and using the wrong one causes real bugs. This counts all four: UTF-8 bytes, Unicode code points, UTF-16 units — which is what JavaScript's .length returns — and graphemes, which is what a reader calls characters.
The gaps between them are where things break. A VARCHAR(255) counts bytes in some databases and characters in others. A DynamoDB key limit counts bytes. A JavaScript length check counts UTF-16 units, so one emoji counts as two. A Twitter-style limit counts graphemes, so an emoji with a skin tone counts as one despite being four code points. The breakdown shows how many characters take one, two, three and four bytes, so you can see exactly where the size is going.
UTF-8 bytes, code points, UTF-16 units and graphemes — the four things that all get called "length" and are all different.
How many characters take one, two, three and four bytes, so an oversized field has an obvious explanation.
Uses the browser's own segmenter, so an emoji with a skin tone counts as one character rather than four.
Set a byte or character limit and see the headroom, which is the actual question behind most visits.
Every count updates on each keystroke, so trimming a value to fit is immediate.
Any string — a field value, a message, a key.
UTF-8 bytes, code points, UTF-16 units and graphemes, side by side.
How many characters take one, two, three or four bytes each.
Set a byte or character limit and see how much headroom is left.
It depends. MySQL VARCHAR(255) counts characters, but the index key length is in bytes — which is why a utf8mb4 column can exceed an index limit. PostgreSQL varchar counts characters. Check both.
Because .length counts UTF-16 units, and any code point above U+FFFF takes two of them. Use [...string].length for code points, or Intl.Segmenter for graphemes.
What a reader calls a character. An emoji with a skin tone modifier is one grapheme, two code points and eight UTF-8 bytes — and a flag emoji is one grapheme made of two.
One for ASCII, two for most Latin, Greek, Cyrillic, Hebrew and Arabic, three for most CJK and Indic scripts, and four for emoji and rarer scripts.
What people who use the String Byte Counter think of it. Reviews come from visitors and are posted as written.
No ratings yet
Yours would be the first.
0 reviews
Newest first
No reviews yet
Be the first to rate the String Byte Counter. It takes half a minute and no account.
Write the first reviewEvery regex token, searchable, with an example of what it matches.
Convert a hexadecimal string to Base64, standard or URL-safe.
Encode and decode Base58 in the Bitcoin, Ripple or Flickr alphabets.
Convert text to Base64 and back, with full Unicode support.
Press any key and see event.key, event.code and the modifier state.
Convert Base64 back to hexadecimal, with your choice of separator.
Run XPath expressions against your own XML and see every node that matches.
Compile SCSS to plain CSS in your browser — nesting, variables and mixins.