I'm trying to find all words with 3 letters in a string.
So in this list
cat monkey dog mouse
I only want
cat dog
This is my expression:
^[a-zA-Z]{3}$
I tested it with different online regex tester, but none of them matched my expression.
To run a “whole words only” search using a regular expression, simply place the word between two word boundaries, as we did with ‹ \bcat\b ›. The first ‹ \b › requires the ‹ c › to occur at the very start of the string, or after a nonword character.
2.1 Matching a Single Character The fundamental building blocks of a regex are patterns that match a single character. Most characters, including all letters ( a-z and A-Z ) and digits ( 0-9 ), match itself. For example, the regex x matches substring "x" ; z matches "z" ; and 9 matches "9" .
Google Search Console has introduced the use of regular expression to filter results in the performance report. Using the custom filter option at the top of the performance report, you can apply a filter with regex using the Custom (regex) dropdown option.
You should use your match with word boundaries instead of anchors:
\b[a-zA-Z]{3}\b
RegEx Demo
When you use:
^[a-zA-Z]{3}$
It means you want to match a line with exact 3 letters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With