Solved

regex for "<>"

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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Reading the Web.Config using IIS 7.5? 4 36
.NET 2008 VB and C# 6 28
Call Controller Action Method from ASPX 2 15
Create a datatable in vb.net dynamically 1 15
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

810 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