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

doramail05
doramail05 used Ask the Experts™
on
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.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Try this:
[A-Za-z]* / \d{4} / \d{1,}

Open in new window


HTH,
Dan

Commented:
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 '*'

Author

Commented:
having :
CS1009: Unrecognized escape sequence

with the error underline the \d
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

Commented:
RegexBuddy says this should work in C#:

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

Open in new window

Author

Commented:
dan craciun,

                  ok

Commented:
Glad I could help!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial