You should use your match with word boundaries instead of anchors:
\b[a-zA-Z]{3}\b
When you use:
^[a-zA-Z]{3}$
It means you want to match a line with exact 3 letters.
More Related Contents:
- Remove HTML tags from a String
- How to parse a mathematical expression given as a string and return a number? [duplicate]
- Splitting on comma outside quotes
- Regex to match a C-style multiline comment
- Java string split with “.” (dot) [duplicate]
- Splitting a string at every n-th character
- In Java, how do I parse XML as a String instead of a file?
- How to split a string between letters and digits (or between digits and letters)?
- How can non-ASCII characters be removed from a string?
- How to extract numbers from a string and get an array of ints?
- How to split String with some separator but without removing that separator in Java? [duplicate]
- Java – Best way to grab ALL Strings between two Strings? (regex?)
- How do I convert CamelCase into human-readable names in Java?
- How to convert/parse from String to char in java?
- Check and extract a number from a String in Java
- Extracting pairs of words using String.split()
- What is the simplest way to convert a Java string from all caps (words separated by underscores) to CamelCase (no word separators)?
- Why String.replaceAll() in java requires 4 slashes “\\\\” in regex to actually replace “\”?
- Java: Split string when an uppercase letter is found
- Java String.split() Regex
- Extract Integer Part in String
- Remove all empty lines
- Split a string, at every nth position
- Evaluate String as a condition Java
- Java String.split() sometimes giving blank strings
- How to Split a mathematical expression on operators as delimiters, while keeping them in the result?
- Use Java and RegEx to convert casing in a string
- Java String ReplaceAll method giving illegal repetition error?
- String.replaceAll is considerably slower than doing the job yourself
- Remove all occurrences of \ from string