Solved

regex for "<>"

Posted on 2014-02-06
5
351 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

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 …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

729 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