locked
both empty and non-empty RRS feed

  • Question

  • Hi, is there a way for a regular expression to allow both an empty string, or a string following a pattern?  If so, how would you do that?  Thanks!

    Thursday, April 1, 2010 3:10 AM

Answers

  • you have a few options:

     

    (|yourpattern)

     

    or

     

    ^$|yourpattern

    • Proposed as answer by JohnGrove Thursday, April 1, 2010 1:13 PM
    • Marked as answer by eryang Friday, April 23, 2010 2:17 AM
    Thursday, April 1, 2010 8:38 AM