473,406 Members | 2,867 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,406 software developers and data experts.

Regex problems

I need a regular expression that would validate string like this.

aa5677

Any 2 literal characters and then any amount of digits from 1 to ...
aa345k is not valid.

Can someone write this for me.

Thanks
George.
Aug 16 '07 #1
4 1120
On Aug 16, 8:35 pm, "George Ter-Saakov" <gt-...@cardone.comwrote:
I need a regular expression that would validate string like this.

aa5677

Any 2 literal characters and then any amount of digits from 1 to ...
aa345k is not valid.

Can someone write this for me.

Thanks
George.
^[a-zA-Z]{2}\d*$

Aug 16 '07 #2
On Aug 16, 8:35 pm, "George Ter-Saakov" <gt-...@cardone.comwrote:
any amount of digits from 1 to ...
Ah, change ( * ) to ( + ), like this

^[a-zA-Z]{2}\d+$

it will require at least one digit

Aug 16 '07 #3
Thanks, saved me one headache today :)

George.

"Alexey Smirnov" <al************@gmail.comwrote in message
news:11**********************@k79g2000hse.googlegr oups.com...
On Aug 16, 8:35 pm, "George Ter-Saakov" <gt-...@cardone.comwrote:
>I need a regular expression that would validate string like this.

aa5677

Any 2 literal characters and then any amount of digits from 1 to ...
aa345k is not valid.

Can someone write this for me.

Thanks
George.

^[a-zA-Z]{2}\d*$

Aug 16 '07 #4
Yea, thanks
I figured that one myself
After an hour of reading MSDN I gave up and wrote to you guys. But now I
know something about Regex

George.

"Alexey Smirnov" <al************@gmail.comwrote in message
news:11**********************@22g2000hsm.googlegro ups.com...
On Aug 16, 8:35 pm, "George Ter-Saakov" <gt-...@cardone.comwrote:
>any amount of digits from 1 to ...

Ah, change ( * ) to ( + ), like this

^[a-zA-Z]{2}\d+$

it will require at least one digit

Aug 16 '07 #5

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

Similar topics

2
by: Ram Sundaram | last post by:
Hi, I am trying to port some linux code to windows under Visual studio. The regex package currently used is the GNU regex package which calls for <strings.h>. This is not found in visual studio....
7
by: alphatan | last post by:
Is there relative source or document for this purpose? I've searched the index of "Mastering Regular Expression", but cannot get the useful information for C. Thanks in advanced. -- Learning...
3
by: Phil396 | last post by:
I am trying to mix metacharacters and the literal versions in an expression and no matter what I try it does not work. Here is the code customer = Regex.Replace(customer,"$",""); I want to...
7
by: bill tie | last post by:
I'd appreciate it if you could advise. 1. How do I replace "\" (backslash) with anything? 2. Suppose I want to replace (a) every occurrence of characters "a", "b", "c", "d" with "x", (b)...
7
by: Mike Labosh | last post by:
I have the following System.Text.RegularExpressions.Regex that is supposed to remove this predefined list of garbage characters from contact names that come in on import files : Dim...
3
by: jab3 | last post by:
Hello. I"m new to this group, and to JavaScript in general, so please forgive me if I breach local etiquette. I'm trying to implement some client-side 'dynamic' validation on a form. I'm having...
16
by: Mark Chambers | last post by:
Hi there, I'm seeking opinions on the use of regular expression searching. Is there general consensus on whether it's now a best practice to rely on this rather than rolling your own (string)...
3
by: ommail | last post by:
Hi I wonder if regular expressions are in general sower than using classes like String and Char when used for validating/parsing text data? I've done some simple test (using IsMatch()) method...
7
by: =?Utf-8?B?amFj?= | last post by:
Hi, I have problems with following code and don’t find the bug : // Set ArrayList aArray = new ArrayList(); regStr = new Regex(@"\?)*(\d+)\]"); if(text != null && regStr.IsMatch(text))...
31
by: raylopez99 | last post by:
I went through a bunch of Regex examples, and indeed it's quite powerful, including 'groups' using 'matches', word boundaries, lookahead matches, replacing and splitting text,etc--apparently...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.