public class QuantifiersTest extends Object
| Constructor | Description |
|---|---|
QuantifiersTest() |
| Modifier and Type | Method | Description |
|---|---|---|
void |
testMatchPreviousAtLeastRegex() |
The matchPreviousAtLeast regex:
|
void |
testMatchPreviousBetweenRegex() |
The matchPreviousBetween regex:
|
void |
testMatchPreviousNTimesRegex() |
The matchPreviousNTimes regex:
|
void |
testMinMatchOneOrMoreRegex() |
The minMatchOneOrMore regex:
|
void |
testMinMatchPreviousAtLeastRegex() |
The minMatchPreviousAtLeast regex:
|
void |
testMinMatchPreviousBetweenRegex() |
The minMatchPreviousBetween regex:
|
void |
testMinMatchPreviousNTimesRegex() |
The minMatchPreviousNTimes regex:
|
void |
testMinMatchZeroOrMoreRegex() |
The minMatchZeroOrMore regex:
|
void |
testMinMatchZeroOrOneRegex() |
The minMatchZeroOrOne regex:
|
void |
testOneOrMoreRegex() |
The oneOrMore regex:
|
void |
testZeroOrMoreRegex() |
The zeroOrMore regex:
|
void |
testZeroOrOneRegex() |
The zeroOrOne regex:
|
public void testZeroOrMoreRegex()
The zeroOrMore regex:
*
Matches the previous element zero or more times.
In this example we use the following regex:
\d*
It will match any sequence of one or more digits.
public void testOneOrMoreRegex()
The oneOrMore regex:
+
Matches the previous element one or more times.
In this example we use the following regex:
hey*
It will match any "he" String followed by any number of consecutive 'y' character occurrences.
public void testZeroOrOneRegex()
The zeroOrOne regex:
?
In this example we use the following regex:
rai?n
It will match two words:
1: "ran", The case where 'i' happens 0 times.
2: "rain", The case where 'i' happens 1 time.
public void testMatchPreviousNTimesRegex()
The matchPreviousNTimes regex:
{n}
In this example we use the following regex:
\d{2}
This will match two consecutive digits since it matches any digit, i.e. \d, two times.
public void testMatchPreviousAtLeastRegex()
The matchPreviousAtLeast regex:
{n,}
In this example we use the following regex:
\d{2,}
This will match at least two consecutive digits since it matches any digit, i.e. \d, at least 2 times.
public void testMatchPreviousBetweenRegex()
The matchPreviousBetween regex:
{n,m}
In this example we use the following regex:
\d{2,3}
This will match between two or three consecutive digits.
public void testMinMatchZeroOrMoreRegex()
The minMatchZeroOrMore regex:
*?
In this example we use the following regex:
\d*?\.\d
This will match the any digit zero or more times but as few as possible followed by a '.' character then followed by another \d.
public void testMinMatchOneOrMoreRegex()
The minMatchOneOrMore regex:
+?
In this example we use the following regex:
\d+?\.\d
This will match the any digit one or more times but as few as possible followed by a '.' character then followed by another \d.
public void testMinMatchZeroOrOneRegex()
The minMatchZeroOrOne regex:
??
In this example we use the following regex:
\d??\.\d
This will match the any digit zero or one time but as few as possible followed by a '.' character then followed by another \d.
public void testMinMatchPreviousNTimesRegex()
The minMatchPreviousNTimes regex:
{n}?
In this example we use the following regex:
\d{2}?
This will match any digit exactly 2 digits.
public void testMinMatchPreviousAtLeastRegex()
The minMatchPreviousAtLeast regex:
{n,}?
In this example we use the following regex:
\d{2,}?
This will match any digit at least 2 digits but as few as possible.
public void testMinMatchPreviousBetweenRegex()
The minMatchPreviousBetween regex:
{n,m}?
In this example we use the following regex:
\d{2,3}?
This will match any digit between 2 and 3 digits but as few as possible.
Copyright © 2018. All rights reserved.