J
John A Grandy
What's the proper way to write a validation regex so that all leading and
trailing spaces are trimmed before evaluation ? Thanks.
trailing spaces are trimmed before evaluation ? Thanks.
John said:What's the proper way to write a validation regex so that all leading
and trailing spaces are trimmed before evaluation ? Thanks.
John said:What's the proper way to write a validation regex so that all leading
and trailing spaces are trimmed before evaluation ? Thanks.
You could extend that regex, so that leading/trailing spaces are accepted.
Don't forget to trim the value then before you use it.
[ ]*<original RE>[ ]*
Hans Kesting
Marcus Andrén said:On Thu, 29 Sep 2005 11:23:30 +0200, "Hans Kesting"
Almost a correct answer, but you forgot the symbols for matching the
complete string.
^[ ]*<original RE>[ ]*$
^[ ]*<original RE>[ ]*$
That's not true, if it's for use in RegularExpressionValidator (as i suppose
is true for the OP).
RegularExpressionValidator checks, if the whole value matches the RE, not if
it contains a match.
(Internally it adds ^ and $ IMHO.
Christof
Marcus Andrén said:^[ ]*<original RE>[ ]*$
That's not true, if it's for use in RegularExpressionValidator (as i
suppose
is true for the OP).
RegularExpressionValidator checks, if the whole value matches the RE, not
if
it contains a match.
(Internally it adds ^ and $ IMHO.
Christof
Oops. That is what I get for assuming that the validator took a true
regular expression instead of a deformed one.
Marcus
Marcus Andrén said:^[ ]*<original RE>[ ]*$
That's not true, if it's for use in RegularExpressionValidator (as i
suppose
is true for the OP).
RegularExpressionValidator checks, if the whole value matches the RE, not
if
it contains a match.
(Internally it adds ^ and $ IMHO.
Christof
Oops. That is what I get for assuming that the validator took a true
regular expression instead of a deformed one.
Marcus
Also, in the form :
\s*<original RE>\s*
why is it possible to not include the [] ?
In other words, why is it that the form does not have to be:
[\s]*<original RE>[\s]*
Thanks.
John said:In this format:
[ ]*<original RE>[ ]*
when I move the cursor over it , I am finding a what appears to be a space
character between the [].
Is that how a regex works? It can identify a single space as a character
to be matched ?