locked
How to build a Regular Expression for this scenario for DataAnnotation validation RRS feed

  • Question

  • User269846090 posted

    I have a regular expression to allow only alphabets but it should allow only T and F in the alphabets. How to do that?

    Wednesday, May 20, 2015 9:33 AM

Answers

  • User281315223 posted

    So you want to allow strings that only consist of T and F? If that is the case the following would work :

    ^[TFtf]+$

    This would only allow strings that consist of T and F (in both cases). If you needed only upper-case or lower case, simply remove them out of the square braces seen above.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 20, 2015 9:39 AM

All replies

  • User281315223 posted

    So you want to allow strings that only consist of T and F? If that is the case the following would work :

    ^[TFtf]+$

    This would only allow strings that consist of T and F (in both cases). If you needed only upper-case or lower case, simply remove them out of the square braces seen above.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 20, 2015 9:39 AM
  • User269846090 posted

    Good. Thank you Rion.

    Thursday, May 21, 2015 9:16 AM