473,320 Members | 2,161 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 Length

34
Hello all.

I couldn't see a regular expression forum and seeing as I am coding it in .NET, into the .NET forum I threw it. Now:

I have a regular expression that needs to ensure a string contains at least one number, at least one character and is between 6 and 13 characters. I have:

Expand|Select|Wrap|Line Numbers
  1. (([A-Za-z]+)([0-9]+)|(([0-9]+)([A-Za-z]+)))
  2.  
This successfully validates the first 2 requirements (at least one number and at least one character), however when I try to also include validation for the length it fails.
Expand|Select|Wrap|Line Numbers
  1. (([A-Za-z]+)([0-9]+)|(([0-9]+)([A-Za-z]+))){6,13}
  2.  
Any help would be much appreciated :)
Nov 22 '07 #1
2 1160
dip_developer
648 Expert 512MB
Hello all.

I couldn't see a regular expression forum and seeing as I am coding it in .NET, into the .NET forum I threw it. Now:

I have a regular expression that needs to ensure a string contains at least one number, at least one character and is between 6 and 13 characters. I have:

Expand|Select|Wrap|Line Numbers
  1. (([A-Za-z]+)([0-9]+)|(([0-9]+)([A-Za-z]+)))
  2.  
This successfully validates the first 2 requirements (at least one number and at least one character), however when I try to also include validation for the length it fails.
Expand|Select|Wrap|Line Numbers
  1. (([A-Za-z]+)([0-9]+)|(([0-9]+)([A-Za-z]+))){6,13}
  2.  
Any help would be much appreciated :)
i find nothing wrong in your expression ....only you might have to give a $ sign after {6,13} like

Expand|Select|Wrap|Line Numbers
  1. (([A-Za-z]+)([0-9]+)|(([0-9]+)([A-Za-z]+))){6,13}$
  2.  
Nov 22 '07 #2
Murdz
34
Thanks for your reply dip, but that only seems to validate that at least 6 characters AND 6 digits are entered; whereas I want a minimum of 6 chars OR digits (as long as there is at least 1 of each).

Expand|Select|Wrap|Line Numbers
  1. ^((([A-Za-z]+) ([0-9]+)){6,13})|((([0-9]+)([A-Za-z]+)){6,13})$
  2.  
Also seems to fail
Nov 22 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Jeff Sandler | last post by:
I have a page that accepts input from many textboxes. Many of the textboxes are intended to accept dates and times, thus, I expect only digits to be entered. I originally tested using parseInt...
4
by: Neri | last post by:
Some document processing program I write has to deal with documents that have headers and footers that are unnecessary for the main processing part. Therefore, I'm using a regular expression to go...
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...
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: Brian Kitt | last post by:
I have a process where I do some minimal reformating on a TAB delimited document to prepare for DTS load. This process has been running fine, but I recently made a change. I have a Full Text...
14
by: olekristianvillabo | last post by:
I have a regular expression that is approximately 100k bytes. (It is basically a list of all known norwegian postal numbers and the corresponding place with | in between. I know this is not the...
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...
18
by: Lit | last post by:
Hi, I am looking for a Regular expression for a password for my RegExp ValidationControl Requirements are, At least 8 characters long. At least one digit At least one upper case character
0
by: altavim | last post by:
Usually when you make regular expression to extract text you are starting from simple expression. When you got to know target text, you are extending your expression. Subsequently very hard to ready...
1
by: NvrBst | last post by:
I want to use the .replace() method with the regular expression /^ %VAR % =,($|&)/. The following DOESN'T replace the "^default.aspx=,($|&)" regular expression with "":...
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...
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: 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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.