Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 294
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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