Sunday, 23 April 2017

Check that an input is in a certain format

I am trying to create a regex that checks that an input is in the following formats:

% word word number # % word word number #     - OK
% word word # % word word #    - OK
% word word word # % word word #    - OK
% # %% word word #    - NOT OK

So between % and # there can be between 1-8 word, and only 1 or none number, number must also be at the end. I don't mind about spaces between the symbols and the text, or numbers, just the words between, so %word word#%word word# or %word word number#%word word# is accepted but %wordword#%wordword# or %wordwordnumber#%wordwordnumber# is not okay. Feel free to ask me anything .



via nonerth

No comments:

Post a Comment