locked
Regex expresssion requested RRS feed

  • Question

  • User1453549677 posted
    Enforce the following validation rules for Business Partner Number:
    1. Only allow alphanumeric characters (A-Z and 0-9)
    2. Restrict to a character string of nine
    3. Restrict the first three characters to DOD.
    4. Cannot be blank (null)
    Thursday, August 6, 2015 5:35 PM

Answers

  • User325035487 posted

    Matching just a word

    ^(DOD)([A-Za-z0-9]{6})$

    or

    ^(DOD)([A-Z0-9]{6})$

    if you dont want small letters

    ---

    If this word is from a paragraph \b(DOD)([A-Za-z0-9]{6})\b

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 6, 2015 9:20 PM

All replies

  • User325035487 posted

    Matching just a word

    ^(DOD)([A-Za-z0-9]{6})$

    or

    ^(DOD)([A-Z0-9]{6})$

    if you dont want small letters

    ---

    If this word is from a paragraph \b(DOD)([A-Za-z0-9]{6})\b

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 6, 2015 9:20 PM
  • User1453549677 posted

    Thanks.

    Friday, August 7, 2015 9:41 AM
  • User1453549677 posted

    I am trying to now validate alphanumeric 16 digit, that allows a blank field. Here's what I've got:

    @"^\s*|[a-zA-Z0-9]{16}$"

    This accepts "2222222222222222222222222222" (more than 16 characters)

    Can you help?

    Friday, August 7, 2015 1:25 PM
  • User325035487 posted

    Try this ^([A-Za-z0-9 ]{16})+$

    Test using http://www.regexr.com/

    Saturday, August 8, 2015 2:48 AM