Solved

regex for "<>"

Posted on 2014-02-06
5
348 Views
Last Modified: 2014-02-06
What is the regex pattern for "<anyword>" or "<<anyword>>" ?
0
Comment
Question by:VBdotnet2005
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

739 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