regex for "<>"

Posted on 2014-02-06
Last Modified: 2014-02-06
What is the regex pattern for "<anyword>" or "<<anyword>>" ?
Question by:VBdotnet2005
  • 3
  • 2
LVL 35

Expert Comment

by:Terry Woods
ID: 39840736
If you want a pattern that matches both those cases, and doesn't allow any non-alphabetic characters, then this is nice and simple:

Open in new window

There are other ways of doing it, but I think that way is easiest to understand.
LVL 35

Expert Comment

by:Terry Woods
ID: 39840739
If the string you're testing against must contain no other characters, then you'll want to use this one instead:

Open in new window


Author Comment

ID: 39840740
I am sorry. I didn't even think about number. What if it can be anything inside "<alph or non-alpha>" and ignore lower or upper case?
LVL 35

Accepted Solution

Terry Woods earned 500 total points
ID: 39840744
If you want to just allow alphanumeric:

Open in new window

If you want to just allow alphanumeric and space characters:
<[a-zA-Z0-9 ]+>|<<[a-zA-Z0-9 ]+>>

Open in new window

If you want to allow any character except a > character:

Open in new window


Author Comment

ID: 39840761
Thank you. That works for me.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
WPF - Tooltips for ComboBox items 5 33
Anyway to make "All" the default in the dropdown? 6 34
Replace &lt; with < 14 54
Ajax Panel Not Updating When Triggered By Timer 4 40
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Sending a Secure fax is easy with eFax Corporate ( First, just open a new email message. In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now