473,387 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Regular Expression question

Hi All,

I've got a textbox where I want to make sure the person has entered at least
3 characters before submitting (it's like a partial name lookup type of
query), so I don't want them to just enter "a" or "e" in the box and bring
back everyone with an "a" or "e" in their name.

I figure that a regular expression validation is the way to go, and I tried
this:
ValidationExpression="^([a-zA-z0-9\s]{3,255})$"

However, this doesn't work all the time, because a user can enter "dr." or
"st." and that is 3 characters but the validation fails, because the "." is
not recognized as a character.

So, can some kind soul help me out with the accurate regular expression for
what I want to accomplish?

Thanks,
Brian
Aug 28 '07 #1
4 1712
Hi Brian,
Why a regular expression? I would just use "TextBox.Text..Length 3".
If you really want a regualr expression, try ".{3,255}". The "." will
match anything (except newlines).
Ethan

Ethan Strauss Ph.D.
Bioinformatics Scientist
Promega Corporation
2800 Woods Hollow Rd.
Madison, WI 53711
608-274-4330
800-356-9526
et***********@promega.com

"Brian Simmons" wrote:
Hi All,

I've got a textbox where I want to make sure the person has entered at least
3 characters before submitting (it's like a partial name lookup type of
query), so I don't want them to just enter "a" or "e" in the box and bring
back everyone with an "a" or "e" in their name.

I figure that a regular expression validation is the way to go, and I tried
this:
ValidationExpression="^([a-zA-z0-9\s]{3,255})$"

However, this doesn't work all the time, because a user can enter "dr." or
"st." and that is 3 characters but the validation fails, because the "." is
not recognized as a character.

So, can some kind soul help me out with the accurate regular expression for
what I want to accomplish?

Thanks,
Brian
Aug 28 '07 #2
ValidationExpression= ".{3,255}"

Btw the ^ and $ at the beginning and end of the expression are redundant in
RegularExpressionValidator since the validation code checks that the match
occurs at position zero and match length equals validated string length.
"Brian Simmons" <ce******@newsgroup.nospamwrote in message
news:OX**************@TK2MSFTNGP05.phx.gbl...
Hi All,

I've got a textbox where I want to make sure the person has entered at
least 3 characters before submitting (it's like a partial name lookup type
of query), so I don't want them to just enter "a" or "e" in the box and
bring back everyone with an "a" or "e" in their name.

I figure that a regular expression validation is the way to go, and I
tried this:
ValidationExpression="^([a-zA-z0-9\s]{3,255})$"

However, this doesn't work all the time, because a user can enter "dr." or
"st." and that is 3 characters but the validation fails, because the "."
is not recognized as a character.

So, can some kind soul help me out with the accurate regular expression
for what I want to accomplish?

Thanks,
Brian

Aug 29 '07 #3
On 28 , 20:01, "Brian Simmons" <centr...@newsgroup.nospamwrote:
Hi All,

I've got a textbox where I want to make sure the person has entered at least
3 characters before submitting (it's like a partial name lookup type of
query), so I don't want them to just enter "a" or "e" in the box and bring
back everyone with an "a" or "e" in their name.

I figure that a regular expression validation is the way to go, and I tried
this:
ValidationExpression="^([a-zA-z0-9\s]{3,255})$"

However, this doesn't work all the time, because a user can enter "dr." or
"st." and that is 3 characters but the validation fails, because the "." is
not recognized as a character.

So, can some kind soul help me out with the accurate regular expression for
what I want to accomplish?

Thanks,
Brian
If you want limit possible characters with letters, numbers and dot:
[a-zA-Z0-9\.]{3,}
It can be shorter [\w\.]{3,} but in that case it also allows
underscore.

Regards,
Mykola
http://marss.co.ua

Aug 29 '07 #4
Hello Sherif,
ValidationExpression= ".{3,255}"

Btw the ^ and $ at the beginning and end of the expression are
redundant in RegularExpressionValidator since the validation code
checks that the match occurs at position zero and match length equals
validated string length.
You might also want to take alook at this article:
http://www.informit.com/articles/art...&seqNum=6&rl=1

It describes how to make a CustomValidator which will do a length check.
Should be quite simple to let it check both min and maxlength.
"Brian Simmons" <ce******@newsgroup.nospamwrote in message
news:OX**************@TK2MSFTNGP05.phx.gbl...
>Hi All,

I've got a textbox where I want to make sure the person has entered
at least 3 characters before submitting (it's like a partial name
lookup type of query), so I don't want them to just enter "a" or "e"
in the box and bring back everyone with an "a" or "e" in their name.

I figure that a regular expression validation is the way to go, and I
tried this:
ValidationExpression="^([a-zA-z0-9\s]{3,255})$"
However, this doesn't work all the time, because a user can enter
"dr." or "st." and that is 3 characters but the validation fails,
because the "." is not recognized as a character.

So, can some kind soul help me out with the accurate regular
expression for what I want to accomplish?

Thanks,
Brian
--
Jesse Houwing
jesse.houwing at sogeti.nl
Aug 29 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Vibha Tripathi | last post by:
Hi Folks, I put a Regular Expression question on this list a couple days ago. I would like to rephrase my question as below: In the Python re.sub(regex, replacement, subject)...
5
by: Bradley Plett | last post by:
I'm hopeless at regular expressions (I just don't use them often enough to gain/maintain knowledge), but I need one now and am looking for help. I need to parse through a document to find a URL,...
10
by: Lee Kuhn | last post by:
I am trying the create a regular expression that will essentially match characters in the middle of a fixed-length string. The string may be any characters, but will always be the same length. In...
18
by: Q. John Chen | last post by:
I have Vidation Controls First One: Simple exluce certain special characters: say no a or b or c in the string: * Second One: I required date be entered in "MM/DD/YYYY" format: //+4 How...
5
by: Ryan | last post by:
HELLO I am using the following MICROSOFT SUGGESTED (somewhere on msdn) regular expression to validate email addresses however I understand that the RFP allows for "+" symbols in the email address...
7
by: norton | last post by:
Hello, Does any one know how to extact the following text into 4 different groups(namely Date, Artist, Album and Quality)? - Artist - Album Artist - Album - Artist - Album - Artist -...
7
by: Billa | last post by:
Hi, I am replaceing a big string using different regular expressions (see some example at the end of the message). The problem is whenever I apply a "replace" it makes a new copy of string and I...
6
by: Ludwig | last post by:
Hi, i'm using the regular expression \b\w to find the beginning of a word, in my C# application. If the word is 'public', for example, it works. However, if the word is '<public', it does not...
3
by: Zach | last post by:
Hello, Please forgive if this is not the most appropriate newsgroup for this question. Unfortunately I didn't find a newsgroup specific to regular expressions. I have the following regular...
25
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.