Regex - Find any string that is surrounded by "<" and ">"

Curto123
Curto123 used Ask the Experts™
on
Is there a simple regular expression that will find any string contained with < and >?  I am working through textual data and I am looking for certain patterns.  For instance, I have
"<Employee Date Of Birth>", this I would want to find.

I have some examples that mostly work, such as:
"<([,'/ A-Za-z0-9\-]+)>"
but this fails to find "<(date of birth)>" because it doesn't find the parentheses.  I could research and figure out how to include the parenetheses, but then I will stumble upon another character it won't find, and so on, and so on...

Seems to be there is a simple solution that I cannot find in any of the examples.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2010
Commented:
Try a pattern like this:


"<[^>]+>"

Patrick

Author

Commented:
Well, that works better, but it isn't finding this:

<(birth)>

Parentheses?
Top Expert 2010

Commented:
Please post a fuller sample of the code you are using, and the string you are running it against.

The parentheses should not be a problem.  At least, I would not expect that they would.
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

Author

Commented:
You are correct, it is finding it, my problem is elsewhere.

Still checking a few others, but I think you've nailed it for me.  Points should be forthcoming...

Commented:
Try the following:

"<(.*?)>"

Commented:
Ahh, I see that you already got a solution... My solution will also return you the text inside the < > using a non greedy expression

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial