V
Vijayaraghavan Kalyanapasupathy
Hi,
I am trying to write a regular expression to match the following
patterns:
\$:xml-ms\{((([a-zA-Z_]+\w*)+(\.([a-zA-Z_]+\w*))+){1,1} | (\$environment
\{"([a-zA-Z_]+\w*)+(\.([a-zA-Z_]+\w*))*"\}){1,1})\}
Here is what it is supposed to do:
In general match all patterns of the form:
$:xml-ms{ <something> }
where something is one of:
Variable:
--------
X.y.z
_x._y.z
m
but not
..Y.
..Y.Z
09.abs.d
Essentially each component of the "dotted" expression is like an
identifier matching:
[A-Za-z_]+\w*
I handle this by the regex:
(([a-zA-Z_]+\w*)+(\.([a-zA-Z_]+\w*))*)
which matches the above types. This does work on the examples I tested.
The test cases are:
Should match: Hi $:xml-ms{_._.x}
Should match: Hi $:xml-ms{_09._87.x}
Should match: Hi $:xml-ms{_09.abc.y}
Should not match: Hi $:xml-ms{_09.87.x}
Should not match: Hi $:xml-ms{_09._87.}
Should not match: Hi $:xml-ms{abs.87.x}
Should not match: Hi $:xml-ms{._a8d7c.x}
Should not match: Hi $:xml-ms{a.._}
The above works fine and as expected.
Environment variable:
--------------------
$environment{"<variable>"}
This can be expressed as:
\$environment\{"([a-zA-Z_]+\w*)+(\.([a-zA-Z_]+\w*))*"\}
Which should match
$environment{"x.y.z"}
and so on just as above but with the surrounding extras!
When I combine the two regular expressions with the choice |
it doesn't work even though the input I tried is the same as above.
Any suggestions,
thanx,
-vijai.
I am trying to write a regular expression to match the following
patterns:
\$:xml-ms\{((([a-zA-Z_]+\w*)+(\.([a-zA-Z_]+\w*))+){1,1} | (\$environment
\{"([a-zA-Z_]+\w*)+(\.([a-zA-Z_]+\w*))*"\}){1,1})\}
Here is what it is supposed to do:
In general match all patterns of the form:
$:xml-ms{ <something> }
where something is one of:
Variable:
--------
X.y.z
_x._y.z
m
but not
..Y.
..Y.Z
09.abs.d
Essentially each component of the "dotted" expression is like an
identifier matching:
[A-Za-z_]+\w*
I handle this by the regex:
(([a-zA-Z_]+\w*)+(\.([a-zA-Z_]+\w*))*)
which matches the above types. This does work on the examples I tested.
The test cases are:
Should match: Hi $:xml-ms{_._.x}
Should match: Hi $:xml-ms{_09._87.x}
Should match: Hi $:xml-ms{_09.abc.y}
Should not match: Hi $:xml-ms{_09.87.x}
Should not match: Hi $:xml-ms{_09._87.}
Should not match: Hi $:xml-ms{abs.87.x}
Should not match: Hi $:xml-ms{._a8d7c.x}
Should not match: Hi $:xml-ms{a.._}
The above works fine and as expected.
Environment variable:
--------------------
$environment{"<variable>"}
This can be expressed as:
\$environment\{"([a-zA-Z_]+\w*)+(\.([a-zA-Z_]+\w*))*"\}
Which should match
$environment{"x.y.z"}
and so on just as above but with the surrounding extras!
When I combine the two regular expressions with the choice |
it doesn't work even though the input I tried is the same as above.
Any suggestions,
thanx,
-vijai.