.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

RegEx for numbers, letters & underscores only

Posted By:      Posted Date: August 30, 2010    Points: 0   Category :ASP.Net
I have this code:public bool IsAlphaNumeric(String strToCheck){  Regex objAlphaNumericPattern=new Regex("[^a-zA-Z0-9]");  return !objAlphaNumericPattern.IsMatch(strToCheck); } how do I modify the Regex to also accept underscores? 

View Complete Post

More Related Resource Links

Use letters instead of numbers for document versions

Is it possible to use letters instead of numbers for document versions? In sharepoint, drafts are numbered 0.1, 0.2,... 1.1, 1.2, 1.3, etc. and published versions are 1.0, 2.0, etc. But due to company's procedures we should use a different system using letters (A, B, C...). Is that possible? If not, would it be possible to add some property to the documents to add the version letter? I know it may be difficult because the letter can be calculated just after sharepoint assigned the version number... :-(

Regex match a number between 100 and 200 and no letters


Hello i`m new in regex and i relly need some help how to fin a solution in this problem

match a number between 100 and 200 inclusive and no letters allowed

Thx in advance hope some one will help me with this

Best regards


Regular Expression Validator - Numbers only no letters no spaces

Hey, I'm looking for the formula for a validator that will accept numbers only.  No letters no spaces.  I read this post:

But, this examples stills allows spaces.  Is there a formula that will allow numbers only?

Generate Random Numbers

SQL Server has a built-in function that generates a random number, the RAND() mathematical function. The RAND math function returns a random float value from 0 through 1.

Regex pattern for validating IPv6


Can anyone can make a regular expression pattern for validating IPv6 (not IPv4)?

Ipv6 has many formats and aliases. I tried making the pattern but written in a lot of codes (i'm not sure my code below will be 100% accepting valid formats and 100% declines invalid formats).


Two numbers after dot



How to do this:

10 becames 10.00

12.3 becames 12.30

14.23 becames 14.23

Thanks you

accept numbers only , telephone validation



my requirement is textbox has to accept only numbers and  " ( ) - " symbols only.

any code plz


Regex.replace [h2] to


I try to replace [h2] to <h2>
I use this coding:

string o = "<h2>test</h2>";
o = Regex.Replace(o, "[h2]", "<h2>");
o = Regex.Replace(o, "[/h2]", "</h2>");


But the result after the first regex is:


So that is not what i want.
After the first 1, he should make:


Whats wrong?

Add page numbers for paging in data view web part


Hello all,

Has anyone found a solution that will allow me to have page numbers for paging in a data view web part. For instance, if I have 40 items/rows and I set the paging to display 10 items, I'd like the paging to show 1 2 3 4 rather than showing 1-10 and having to click next over and over to get to a specific item.

I found this article, but it is for 2003 and doesn't seem to apply to 2007 or if it does I am not able to really figure out how.


Please help!

Thanks in advance.


Last numbers from a string


I need a vb function to determine the last numerical characters in a string. For example, if the string is Step1, I need it to return 1. If the string is Step32, I need it to return 32.

I'm aware of the string functions like Right, Instr, etc but I'm just not sure how to get what I need. Any suggestions?

regex: How to allow a comma?

Hi,How to allow a comma?"^ \ $? (\ D (1.3),? (\ D (3 },?)* \ d (3) (\. \ D (0.2))? | \ D (1.3) (\. \ d (0.2))? | \. \ d (1.2 }?)$"  This is works, I need character ","Helpthanks

multi-line regex in C#

Hi, I am sure this is really simple, but i can't figure it out. I have a string that looks like this: REV=A1 STATUS=Working I would like to grab 'A1' and 'Working', in a single regex, but i cannot seem to handle the linebreak. I have tried putting something together in Rad's Regular expressions designer and this pattern will match it all: REV=(?<Rev>.{2}) STATUS=(?<Status>.+) but i don't know to write a two-lined regex in C#. I have also tried to include the linebreak, with both \n and \r, but none of them worked. So, how is my pattern suppoed to look for this?Nicolai Søndergaard LM Glasfiber A/S

I need a regex for the following sentence

I have a line of text which is as follows  : This should occur before variable1 = 1 variable2 =2 variable3=6 variable4=9   I want a regex which checks if this text (This should occur before ) comes before  the string of the variables (variable1, variable2, variable3, variable4 ) and also  should pass if the placement of the variables can occur anywhere in the sentence.Also the regex should pass only if the variable4 has a value greater than 9.  

Regex for checking number greater than 9

Hi All , I need to write a regex which can check for a number greater than equal to 9 .  

Exclude a word regex

Currently i am using one regex for accepting some records from a file.  That regex is ^[a-zA-Z0-9| ].*$. This regex accepts record starting with alphanumerics or blank space.I want to modify this regex such that, previous conditions should be there and regex should not accept record starting with word 'bbb'. Which regex should be used?

Need RegEx for four decimal place

Hello All, I have total 19 digits in which i have 4 decimal place. What would be the pattern. ThanksBizTalk Beginner
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