There is no single quantifier that means “exactly m or n times”. The way you are doing it is fine.
An alternative is:
X{m}(X{k})?
where m < n
and k
is the value of n-m
.
More Related Contents:
- Java equivalent to PHP’s preg_replace_callback
- Find everything between two XML tags with RegEx
- Regular expression to validate username
- Find the highest number between two literal strings using a Regular Expression
- How to parse a string that contains value only needed partially to an arraylist? [closed]
- Match multiline text using regular expression
- Regex to match a C-style multiline comment
- Regex for matching something if it is not preceded by something else
- Parsing XML with REGEX in Java
- Signing PDFs on a server document using a signature from the user
- Java – Best way to grab ALL Strings between two Strings? (regex?)
- regex: How to escape backslashes and special characters?
- Check and extract a number from a String in Java
- Can I replace groups in Java regex?
- How to add features missing from the Java regex implementation?
- Is Java RegEx case-insensitive?
- Java String.split() sometimes giving blank strings
- Constructing regex pattern to match sentence
- pattern.matcher() vs pattern.matches()
- How to handle requests that includes forward slashes (/)?
- String.split() *not* on regular expression?
- java string split on all non-alphanumeric except apostrophes
- Find the first occurrence with Regex
- Java String ReplaceAll method giving illegal repetition error?
- Can java.util.regex.Pattern do partial matches?
- Find all words with 3 letters with regex
- String.replaceAll is considerably slower than doing the job yourself
- Remove all occurrences of \ from string
- Extract ip addresses from Strings using regex
- Validate if input string is a number between 0-255 using regex