regex - C# Check if filename ends with pattern -


with list of file names below:

  • foo.pdf
  • foo(1).pdf
  • foo(2).pdf
  • foo(321).pdf

how can check if file name ends pattern (n).extension? , if does, how filename without (n) part?

this seems work

void main() {     string test = "file(321).pdf";     string pattern = @"\([0-9]+\)\.";     bool m = regex.ismatch(test, pattern);     if(m == true)        test = regex.replace(test, pattern, ".");     console.writeline(test); } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -