Validate a string with Regex

1

I need to validate the name of a file that has the following name NWD[0-9] PADRAO - . The literal part will always be the same, what can vary are the numbers.

I would like to know how to do this with Regex .

    
asked by anonymous 12.04.2018 / 21:30

2 answers

3

Regex is almost the one that you put in the question, but adding the "+" operator that indicates "one or more occurrences of the list". Example:

/ NWD [0-9] + PATTERN - /

See the example in action

    
12.04.2018 / 21:44
3

The Regex that will solve your problem is:

  

(NWD+[0-9]*)( PADRAO \-)

This means that you will always search for NWD followed by 0 a 9 um número qualquer de vezes characters and lastly search for "espaço" PADRAO "espaco" -

This working regex can be checked here .

    
12.04.2018 / 21:51