Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 296
  • Last Modified:

regex on input with certain special characters, certain number only, certain characters

is there any regex where i could retrieve and validate

ASDF / 1031 / 0122223333

where
first is characters
second is 4 digit numeric only
and then numerics (no limitation)

'/' have to be existed.
0
doramail05
Asked:
doramail05
  • 3
  • 2
1 Solution
 
Dan CraciunIT ConsultantCommented:
Try this:
[A-Za-z]* / \d{4} / \d{1,}

Open in new window


HTH,
Dan
0
 
sentnerCommented:
Are there spaces surrounding the '/' characters (there are in the example).

Simple regex to match that pattern:

^[A-Z]{4} / \d{4} / \d+$

If no spaces should be there, then this:
^[A-Z]{4}/\d{4}/\d+$

If the last section can be blank (zero or more digits) then you can replace the '+' with '*'
0
 
doramail05Author Commented:
having :
CS1009: Unrecognized escape sequence

with the error underline the \d
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
Dan CraciunIT ConsultantCommented:
RegexBuddy says this should work in C#:

@"[A-Za-z]* / \d{4} / \d{1,}"

Open in new window

0
 
doramail05Author Commented:
dan craciun,

                  ok
0
 
Dan CraciunIT ConsultantCommented:
Glad I could help!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now