.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

how does the string validation work for this regular expression?

Posted By:      Posted Date: October 07, 2010    Points: 0   Category :WPF
 _strInt = value.ToString();
Regex objPattern = new Regex("[^ a-zA-Z]" ); if (objPattern.IsMatch(_strInt)) { return   new ValidationResult(true , null );
   } else return new ValidationResult(false , "Value must contain only alphabets" ); } }

if i pass a valid expression as "abc" .. its Failing .
Can some1 explaing how it's failing .

View Complete Post

More Related Resource Links

C++ at Work: Form Validation with Regular Expressions in MFC


I thought I'd use this month's column to describe an interesting app I built using the RegexWrap library described in my article "Wrappers: Use Our ManWrap Library to Get the Best of . NET in Native C++ Code" in this issue.

Paul DiLascia

MSDN Magazine April 2005

How to read string end with question mark in regular expression?

Hello, I'm facing problem when I read string which is ended by question mark. I use in my code as the following. \"?(?<myfield>[^\"]?.*[^\"?]?)\"? If string is ended by question mark, it's not working. Please help me to solve my problem. Thanks. Co Coe

Regular Expression for looking for Colons (:) in a string

Hi I am really struggling with this! Using the regular expression validator I created an expression, thus "\:" to show an error message if the user tries to enter in a name that contains a colon. What I am getting is the error message showing even when there is no colon (:) in the string. What am I doing wrong? Thanks    

Regular Expression, Email Validation, Consective dots name part

Hi All Can you please help me to modify this regex to validate consecutive dots in the name part (before @) of the email string.  For example, i want to disqualify an email string like (george...antony@gmail.com).  But an email string with single dots in the name part should be allowed (george.antony@gmail.com).   This regex is validating the consecutive dots after the @ sign (domain part) .    All other validation with this regex is as expected.   ^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$     Thanks in advance george

Regular expression - exclude certain string

Hi all,I have the following regular expression replacement:<add key="^/([^/]*)\.aspx\?" value="/default.aspx?pagename=$1&"/>What this is used for is URL re-writing, i.e. if a page comes in with the path "/test.aspx", it goes to the actual path which is "/default.aspx?pagename=test"This works fine, but it catches all page names. I would like to exclude a particular page name so it is not rewritten, for example if the page was called "exclude.aspx" it would not rewrite to "/default.aspx?pagename=exclude" but stay as "exclude.aspx".How do I modify ^/([^/]*)\.aspx\?so it excludes a certain page name?Thanks!

Validation Summary with regular Expression validator


I have a page that im using Validation Summary on. I have 5 out of 8 fields that im validating. All 5 have required validators and 1 of the 5 also has regularexpressionvalidator with it.

When the page load and i click the submit, all the fields show my red * next to them and the individual messages down in the summary. Thats find, but im having issues with checking the field with the regex validation when you submit the form again. At the moment, i had added a if condition on the button event and it is preventing the form from submitting and the field is showing the red * next to it, but my message from the regex validator does not display in the summary. Actually the summary doesnt even show up. The regex validator works when you tab out of the field by placing the red *, but the actual error message doesnt display in the summary, so you wouldnt know why there is an issue.


I have the following as a test, def isnt correct, but was trying to show the summary with the value from my regex validator:

        protected void btnInfo_Click(object sender, EventArgs e)
            if (!Page.IsValid)
                vsSumm.ShowSummary = true;

How to use Regular Expression to find a particular pattern and its index in the string??



I need some help here. I have a document containing some string like the following:


Now what I need is that I need to extract this "BusinessGoal" which as you can see, is 32 characters ahead after "-" (hyphen) and change it's case to uppercase.

The real challange is that, This "BusinessGoal" should only be replaced only and only where there is "Ref-<any 32 characters>" before it and not all. So if I find something like TypeName = "BusinessGoal"  it will be simply ignored.

So how am I going to make that reg Ex. I think it would be a combination of Regex and String Api. 

Kindly help me out.

Thanks and regards



Fahad Ali Shaikh

replace tab in the string using regular expression

      I want to replace tab space with "|" in the string using regular expressions.
I have tried for

Dim strTabString AS string = "A             B             C "                 
TextBox1.Text = Regex.Replace(strTabString , "\t", "|")
But i m not getting the results.


Regular expression validation



I'm using a regular expression validator on a number forms but I can't get this one (the simplest) to work

The regex pattern is ^(?!Search for) which should stop a user pressing the submit button before valid input is entered.  The result however is that it stops every unput.

Anyone help?

Regular expression: String start with
end with
which ever comes first


Regular expression is hard. Can anyone help me with this one?

I need to get XYZ 123 and abc 134

from this html code below:


<div>XYZ 123<br />

<div>abc 134</div>


 Thank you in advance!

regular expression thar allow except ".aspx" this string


hi i am new in regular expression

can anybody understood me how can i make a regular expression that

allow all the mismatch case  and don't a match case

ex: ".aspx"

( when i put any thing in text box it allow ----a ,ab ,adn.jpg ) result=true

(but when i put =.aspx ) result= false  

Regular expression for splitting string



i have a string like this 


i want to split like this





pls help me 

thanks in advance

Regards, Anoop

Regular Expression Match Exact String


I'm looking for a regular expression that satisfies one of the two conditions (Reg Expression OR Exact String Match W/ Underscores) listed below.





Thanks in advance

Security Briefs: Regular Expression Denial of Service Attacks and Defenses


Microsoft security expert Bryan Sullivan believes denial-of-service blackmail attacks will become more common as privilege escalation attacks become more difficult to execute. He demonstrates how to protect your apps against regular expression DoS threats.

Bryan Sullivan

MSDN Magazine May 2010

Help with regular expression


I am using this regular expression: /.*-lyrics-.*$

and I need the expression find urls like this:

and it do really does that!

The problem is that it finds also this URL:

Whar regular expression should I use to exclude urls that end with /lyrics ?

Thanks :]



Need regular expresion for this string


Hi All,

I would be grateful if some one can provide me regular expression for extracting just  myhomepage from below url:


Thanks in advance for replying(as always).

With Warm Regards,


Regular Expression to Match


Here is the kind of text I want to match via a regular Expression

The id="dgSchedule" is always present in the TAG but its location may differ

The table is span over multiple line/contains white spaces/tabs...

I have the regular expression to match the start and end tag respectively over a single line

\<table .*\>


The problem is to match the whole table span over multiple lines

<table cellspacing="0" rules="all" border="1" id="dgSchedule" style="border-style:None;height:100%;width:100%;border-collapse:collapse;">
	<tr class="blackbar" align="center" style="background-color:#7FB4DE;font-family:Verdana;font-weight:bold;height:20px;">
		<td>From Place</td><td>To Place</td><td>Time</td><td>Bus Type</td>

	</tr><tr style="background-color:#DEECF5;">
	</tr><tr style="background-color:#EFF5FA;">
	</tr><tr style="background-color:#DEECF5;">

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend