Regex to capture anything but <[A-Z]*>
Posted: Wed Feb 07, 2007 1:57 pm
Hi,
I am trying to write a regex to capture anything but < followed by upper case letters followed by >. For example
<YEAR>-<MONTH>-<DAY> => I want to capture - and replace it with ' "-" ' so the output string should be <YEAR> "-" <MONTH> "-" <DAY>
<YEAR>.<MONTH>.<DAY>. => output should be <YEAR> "." <MONTH> "." <DAY> "."
I have tried the following
[^<][^A-Z]*[^>]
[^<[^A-Z]*^>]
(^(<[A-Z]*>)
I am not able to figure out how exactly I will be able to capture and replace it. I can do it in otherway by finding indexes of string literals and then doing math but that is not a clean way to do this.
Any help to write this will be appreciated.
Thank you.
I am trying to write a regex to capture anything but < followed by upper case letters followed by >. For example
<YEAR>-<MONTH>-<DAY> => I want to capture - and replace it with ' "-" ' so the output string should be <YEAR> "-" <MONTH> "-" <DAY>
<YEAR>.<MONTH>.<DAY>. => output should be <YEAR> "." <MONTH> "." <DAY> "."
I have tried the following
[^<][^A-Z]*[^>]
[^<[^A-Z]*^>]
(^(<[A-Z]*>)
I am not able to figure out how exactly I will be able to capture and replace it. I can do it in otherway by finding indexes of string literals and then doing math but that is not a clean way to do this.
Any help to write this will be appreciated.
Thank you.