Solved

regex for "<>"

Posted on 2014-02-06
5
335 Views
Last Modified: 2014-02-06
What is the regex pattern for "<anyword>" or "<<anyword>>" ?
0
Comment
Question by:VBdotnet2005
  • 3
  • 2
5 Comments
 
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:
<[a-zA-Z]+>|<<[a-zA-Z]+>>

Open in new window

There are other ways of doing it, but I think that way is easiest to understand.
0
 
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:
^(<[a-zA-Z]+>|<<[a-zA-Z]+>>)$

Open in new window

0
 

Author Comment

by:VBdotnet2005
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?
0
 
LVL 35

Accepted Solution

by:
Terry Woods earned 500 total points
ID: 39840744
If you want to just allow alphanumeric:
<[a-zA-Z0-9]+>|<<[a-zA-Z0-9]+>>

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

0
 

Author Comment

by:VBdotnet2005
ID: 39840761
Thank you. That works for me.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

758 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

22 Experts available now in Live!

Get 1:1 Help Now