Click here to Skip to main content
14,921,072 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
<pre><pre>Required Regular expression Validation Start two Fixed character and then after Numeric fixed Character.

Example:

if character start with AB then allow 20 character
- Length : additional 20 numbers. - Example : ABcD3456789012345678cc If "AB" then 20 characters. AB+20 AlphaNumeric

if character start with XY then allow 14 character
- Length : additional 14 numbers. - Example : XY0123456789012 If "XY" then 14 numbers. XY+12 numbers


(?:AB[\da-zA-Z]{20}|XY\d{14})$ i need in this expression add one condition if string not start with AB or XY then it's allow 0 to 100 character.


What I have tried:

Regex Validation Start two Fixed character and then after Numeric fixed Character
Posted
Updated 10-Sep-20 5:38am
v3

Try:
^(AB\d{20})|(XY\d{14})$

But ... your second example doesn't match the initial description of "additional 14 digits"
   
Comments
jacky4lad 27-Aug-20 8:34am
   
yes, you are correct mistake i have written wrong information,Thanks for Answer.
it's for workforme.
OriginalGriff 27-Aug-20 9:03am
   
You're welcome!
jacky4lad 10-Sep-20 11:39am
   
(?:AB[\da-zA-Z]{25}|CC\d{14})$ i need in this expression add one condition if string not start with AB or CC then it's allow 0 to 100 character.
OriginalGriff 10-Sep-20 12:05pm
   
And?
What have you tried?
Where are you stuck?
Just a few interesting links to help building and debugging RegEx.
Here is a link to RegEx documentation:
perlre - perldoc.perl.org[^]
Here is links to tools to help build RegEx and debug them:
.NET Regex Tester - Regex Storm[^]
Expresso Regular Expression Tool[^]
RegExr: Learn, Build, & Test RegEx[^]
Online regex tester and debugger: PHP, PCRE, Python, Golang and JavaScript[^]
This one show you the RegEx as a nice graph which is really helpful to understand what is doing a RegEx: Debuggex: Online visual regex tester. JavaScript, Python, and PCRE.[^]
This site also show the Regex in a nice graph but can't test what match the RegEx: Regexper[^]
   
Comments
jacky4lad 10-Sep-20 11:39am
   
(?:AB[\da-zA-Z]{25}|CC\d{14})$ i need in this expression add one condition if string not start with AB or CC then it's allow 0 to 100 character.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900