Solved

regex for "<>"

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

632 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