Avatar of ericlockshine
ericlockshineFlag for United States of America

asked on 

Need some Regex Help

I need help generating a Regex to test the following (I admit I am no good at this):
Up to 5 digits, and an optional 6th Alpha Only character.  So the pattern would be:
0
01
012
0123
01234
01234A

I started with /^\d{1,5}[a-zA-Z]?/ but this allows a letter in the middle, not just as the 6th character.
This will be tested using the System.Text.RegularExpressions.Regex .IsMatch method in a C# class as the characters are being typed (think a specialized input mask).

Thanks for any help!
Regular ExpressionsC#

Avatar of undefined
Last Comment
Dan Craciun
ASKER CERTIFIED SOLUTION
Avatar of Dan Craciun
Dan Craciun
Flag of Romania image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of ericlockshine
ericlockshine
Flag of United States of America image

ASKER

Works like a champ!
Avatar of Dan Craciun
Dan Craciun
Flag of Romania image

Glad I could help.
C#
C#

C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).

98K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo