0
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 may vary are the numbers.
I’d like to know how to do that with Regex.
0
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 may vary are the numbers.
I’d like to know how to do that with Regex.
3
Regex is almost the one you put in the question, but adding the "+" operator that indicates "one or more occurrences from the list". Example:
/NWD[0-9]+ STANDARD -/
Thank you very much!
3
The Regex that will solve your problem is:
(NWD+[0-9]*)( PADRAO \-)
That means it will always seek to NWD
followed by characters of 0 a 9 um número qualquer de vezes
and finally seek to "espaço" PADRAO "espaco" -
This working regex can be checked here.
Thank you very much!
Browser other questions tagged c# regex
You are not signed in. Login or sign up in order to post.
Then some examples would be: "NWD0 PADRAO -", "NWD1 PADRAO -", "NWD2 PADRAO -"?
– David Alves
Yeah, that’s right.
– Ana Carolina
Folks came across another problem. I will have to remove this part of the file name and replace it with blank space. Example filename.Replace("NWD1 PATTERN - ", "") filename.Replace("NWD2 PATTERN - ", ") filename.Replace("NWD3 PATTERN - ", "") If anyone can help me one more time, please! Thank you in advance for your attention!
– Ana Carolina
So it means the name doesn’t just have
NWD0 PADRAO -
and yes other things back ? Otherwise removing that part gets no name at all which is not valid for a file name– Isac
So, it’s the name and a date. Example NWD PADRAO - 201802.xls
– Ana Carolina