473,320 Members | 1,952 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,320 software developers and data experts.

regular expression validator, get rid of unwanted characters

Hi I have a regular expression validator for my username field which
just allows 3 to 30 characters without spaces to be inputted by the
user.

^\S{3,30}$

How can I add to this expression not to allow characters such as
"?/{]-.*'!" etc...?

Thank you.

Nov 19 '05 #1
7 2040
"Steve" <ba****@iranmania.com> wrote in news:1126965826.140231.191620
@o13g2000cwo.googlegroups.com:
Hi I have a regular expression validator for my username field which
just allows 3 to 30 characters without spaces to be inputted by the
user.

^\S{3,30}$

How can I add to this expression not to allow characters such as
"?/{]-.*'!" etc...?

^[A-Za-z]{3,30}$

That should do it
--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.

Newmarket Volvo Sucks! http://newmarketvolvo.tripod.com
Nov 19 '05 #2
Thank you Lucas for the help. I really want to learn how I can specify
which characters I do NOT want as opposed to what I want. Do you know
the syntax for this?

Nov 19 '05 #3
Steve,

Here's an excerpt from:

http://www.15seconds.com/issue/010301.htm (Where there are some great
regular expression examples given.)

A caret (^) at the begging of the pattern string enforces that the target
string should start with the pattern string. But if you put the caret inside
the square brackets [^], then it is altogether a different meaning. Caret
inside the square bracket means "don't match the characters inside the
brackets."
m[^ai]n --- matches men, mend, diamond

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Steve" <ba****@iranmania.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Thank you Lucas for the help. I really want to learn how I can specify
which characters I do NOT want as opposed to what I want. Do you know
the syntax for this?

Nov 19 '05 #4
Thank you very much for your help. I'll check out that article as well.

Nov 19 '05 #5
Steve,

Anytime!

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Steve" <ba****@iranmania.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Thank you very much for your help. I'll check out that article as well.

Nov 19 '05 #6
"Steve" <ba****@iranmania.com> wrote in news:1126971135.813362.284690
@g49g2000cwa.googlegroups.com:
Thank you Lucas for the help. I really want to learn how I can specify
which characters I do NOT want as opposed to what I want. Do you know
the syntax for this?


Just be aware if you go that route, you'll have to filter out a lot of
characters (i.e. numeric, non-ascii, symbols, etc). Basically there are a
lot of combinations you'll need to filter. If you insist on going this
route, you might want to look at Unicode Character sets. .NET's regular
expression parser has the ability to specific sets of characters with
shortcuts:

\p{name} Matches any character in the named character class specified by
{name}. Supported names are Unicode groups and block ranges. For example,
Ll, Nd, Z, IsGreek, IsBoxDrawing.

\P{name} Matches text not included in groups and block ranges specified in
{name}.

It might be best to stick with the KISS principle, and only allow a certain
character set : )

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.

Newmarket Volvo Sucks! http://newmarketvolvo.tripod.com
Nov 19 '05 #7
I think you are right. I did actually want to allow a unicode
characterset to be honest as you guessed. i.e. i want to allow
alphanumeric+ a unicode character set.

Nov 19 '05 #8

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

Similar topics

2
by: Bryce Budd | last post by:
Hi all, I am trying to use a regular expression validator to check for the existence of PO Box in an address textbox. The business rule is "No addresses with PO Boxes are allowed." What I...
3
by: Mark | last post by:
To validate the length of a multiline textbox, I'm told that I have to use a regular expression validator. The regular expression below limits it to 25 characters in length, but if the user enters...
2
by: VSK | last post by:
Hi all, I have a .ascx file with dropdownbox (SSN, EmpName) textbox submit button regular expression validator( controltovalidate is the above textbox) Now i want to change the Regular...
2
by: Nazir | last post by:
Hi I'm using a regular expression validator, but if spaces are entered, it bypasses the validation! I'm using ^{5,100}$
2
by: S.Kartikeyan | last post by:
I have the following problem. I am using the follwing Regular Expression validator(REV) with validator expressions ^{1,2}$ ^{3,20}$ The idea of the first exp is 1 or 2 digits the idea of second...
5
by: John | last post by:
I am new in Regular Expression. Could someone please help me in following expression? 1. the string cannot be empty 2. the string can only contains AlphaNumeric characters. No space or any...
2
by: kieran | last post by:
Hi, I am using Visual Studio 2005 and am trying to use a Regular Expression Validator control. I have a drop down list which contains various names, the first one is "Please Select". I want...
1
by: vtxr1300 | last post by:
I'm having a problem with a regular expression in conjunction with the regular expression validator. I am trying to make sure that when a user browses for a file to upload, it ends in gif, jpeg or...
2
by: Joey | last post by:
Hello guys, I'm trying to learn about regular expressions. I need to be able to use an RE that can evaluate for STRINGS (or specific sequences of characters), not just occurances of characters....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.