Rama Krishna wrote:Am I missing any more information or is it really not that simple?
Rama Krishna wrote:...
Piet,
I would really like to understand how the grouping works i.e., how you got this working.
Could you take a little pain to explain me the regExp please!
I got these from Running the RegExp in EXPRESSO:
Match a suffix but exclude it from the capture:
(?=(?:\\D*\\d){0,9})
where
(?:\\D*\\d){0,9}
meant Match an expression but don't capture it?
where
\D* stands for any character that is not a digit, any number of repititions?
\d is for any digit
what are we capturing here?
Rama Krishna wrote:[-() \\d]{15}
this is the only thing that I know, which means that any character in the character class/set between 0 and 15 repititions.
...
Rama Krishna wrote:Cool,
The positive lookahead did the trick here. We are checking that the string begins with a positive lookahead for
Rama Krishna wrote:meaning that in simpler examples as ones below (which I could understand):
is a non-capturing group in that it will match 42 in bug 42
Rama Krishna wrote:is a zero width positive lookahead that will match var in and in not
where it matches for a character set called 'var' that ends with an '='
Rama Krishna wrote:and a better example:
where \b is beginning or ending
matches a seven-letter-word that contains 'clip' as
eagerly checks looking ahead if there are exactly 7 characters with a \b meaning inside the bracket meaning ending with a character also.
The initial \b is meant for begin with?
Obviously matches ANY word containing 'clip'.
In the same lines, essentially
can be broken down as eagerly look ahead for 9 characters containing both non-numeric and numeric characters together ending by non-numeric characters. So essentially this is where we are limiting the total of numeric characters to a maximum of 9 only and the remainder can be non-numeric.
Rama Krishna wrote:What I do not understand is how the below test case passes:
-1234----56789-
because we did mention that we have a positive look ahead for 9 numeric characters (can be mixed with non-numeric) characters, followed by non-numeric characters only!
I am using java pattern.matches(string) to test if the regular expression matches.
But overall, the string should only have a total of 15 characters from these special characters set which includes numeric characters.
Regards
Rama
What I do not understand is how the below test case passes:
-1234----56789-
because we did mention that we have a positive look ahead for 9 numeric characters (can be mixed with non-numeric) characters, followed by non-numeric characters only!
I am using java pattern.matches(string) to test if the regular expression matches.
But overall, the string should only have a total of 15 characters from these special characters set which includes numeric characters.
Rama Krishna wrote:...
broken down as
eagerly matches up to a maximum of 9 numeric characters or a total of 9 characters (containing both numeric and non-numeric characters) followed by any non-numeric characters. Whereas the test case -1234----56789-
"will match any string that has less than 10 digits in it.
In short:
- it will match an empty string (it has zero \D and it has zero \d)
- it will match a string of arbitrary length (\D*) containing no digits (\d{0,9})
- it will NOT match a string with 10 digits (or more)
"
Rama Krishna wrote:...
so I could not understand how it is imposing this less than 10 digit limitation on the complete 15 characters.
Consider Paul's rocket mass heater. |