Very complicated Regular Expression Help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jayanthigk2004@yahoo.com

    Very complicated Regular Expression Help

    Is it possible to write a regular expression for this ?

    Pattern: 999-99-999

    Where 9 is any number from 0 to 9

    However the user need not enter ALL the digits and dashes as given in
    the format.

    Whatever numbers and dashes he had entered must match the above format,
    from left to right, for only the charcters he has entered.

    For example
    9
    99
    999
    999-
    999-9
    999-99
    999-99-
    999-99-9
    999-99-99
    999-99-999

    Any of the above should result in a match

    Next, he can also put * before or after or before and after any of the
    above combination

    Ex

    *9
    *99
    *999
    *999-
    *999-9
    *999-99
    *999-99-
    *999-99-9
    *999-99-99
    *999-99-999

    Or

    9*
    99*
    999*
    999-*
    999-9*
    999-99*
    999-99-*
    999-99-9*
    999-99-99*
    999-99-999*

    Or

    *9*
    *99*
    *999*
    *999-*
    *999-9*
    *999-99*
    *999-99-*
    *999-99-9*
    *999-99-99*
    *999-99-999*

    Any help is much appreciated.

Working...