SparkyGuy wrote:
> My question is about the metacharacter ".". Using a single ".",
shouldn't it
> match input that consists of a single character, and not match anything
with
> more than one character?
Only if you anchor it, i.e. "^.$" will match lines containing only a
single character. Read this as "At the start of the input, match a
single character, which must be followed by the end of the line"
(newline or end-of-string). A "." alone will match anything, other than
an empty line. Some regex matchers have options to implicitly anchor
the regex but others don't.
Don't know if anyone has suggested this, but one way to achieve the
match you want (in the original post) is to sort the characters of the
field prior to matching. Then match against a simpler regex. The
sorting eliminates the complications of specifying a regex that can cope
with the arbitrary ordering of the input characters. Of course it may
not be the most efficient thing to do depending upon the nature of the
input (quantity, likelihood of match etc...) and a complex regex may be
better.


|