473,549 Members | 2,935 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Regex Help! (unique numbers)

1 New Member
Hey would anyone be able to help me create a regex for Python that has a minimum of 3 characters and a max of 5 characters? the first 3 characters have to be unique and the last two optional characters can be any characters.

Once again, the last two characters can be anything! (even the same as one of the first 3 characters)

This is what I have right now: ^(?:(\w)(?!.*\1 )){3}\w{0,2}$

The only problem with this regex is that it does not allow the last two characters to be the same as any of the first 3. (eg. pfaab doesnt work when it should)

Can anyone help please?
May 21 '14 #1
0 1128

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

Similar topics

5
1670
by: leegold2 | last post by:
I'm new to PHP regex. What I am trying to match is: http://library.dayton.town.net it's a mysql/php field. Then if a match I take some action. But it's not working any help appreciated. Thanks
4
10732
by: August1 | last post by:
A handful of articles have been posted requesting information on how to use these functions in addition to the time() function as the seed to generate unique groups (sets) of numbers - each group consisting of 6 numbers - with a total of 50 groups of numbers. A well-known girl that some publishing companies use to provide introductory level...
4
1637
by: Megan | last post by:
Hi- I need some help/ advise on how to code unique numbers for the primary keys of my 2 tables. I inherited a database that covers information about Hearings and Rulings. Information about the Hearings and Rulings were stored in 1 generic table called Case. I split it into 2 tables, Hearings and Rulings. The problem is that the primary key,...
8
1673
by: rh0dium | last post by:
Hi all, I am using python to drive another tool using pexpect. The values which I get back I would like to automatically put into a list if there is more than one return value. They provide me a way to see that the data is in set by parenthesising it. This is all generated as I said using pexpect - Here is how I use it.. child =...
3
2188
by: ronnchpra | last post by:
Hello, I need help generating 50 unique numbers using rand() BETWEEN 1 and 100 and assign them to a array. I have worked out the number randomization and assignment, but I cant figure out how to generate unique numbers. Can anyone modify this code so that it generates or rather assigns only the unique number to the array: #include <cstdlib>...
0
1616
by: Support Desk | last post by:
That’s it exactly..thx -----Original Message----- From: Reedick, Andrew Sent: Tuesday, June 03, 2008 9:26 AM To: Support Desk Subject: RE: regex help The regex will now skip anything with an '@'in the filename on the assumption it's already in the correct format. Uncomment the os.rename line
4
1107
by: Support Desk | last post by:
Anybody know of a good regex to parse html links from html code? The one I am currently using seems to be cutting off the last letter of some links, and returning links like http://somesite.co or http://somesite.ph the code I am using is
2
1710
by: lmao29 | last post by:
hi guys, i am new to JAVA I am having trouble with array, anyone can help? here is the problem. if i input 10 numbers, how can i count the unique numbers and output them here is the example: Please enter 10 numbers, hitting return after each one: 15 5 10 5
15
4882
by: rajeevs | last post by:
I have an access table with records having unique numbers in one field. I would like to duplicate the record except the unique number and while duplicating I like to give a different number. I have found a code which can generate the random numbers but I dont know where to put it in the button click which creates the duplicate record and cross...
0
7446
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7715
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7469
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7808
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6040
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5368
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3480
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1935
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
757
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.