Split to date

Good day all

I have a saved pdf file named 448473-032020

I want to be able to split it to get the date out which is 032020

fileName.Substring(fileName.Length-11).Replace(".pdf","") is pushing out -32020

Any better way to do this?

thanks

Your logic should not omit the β€œ0” from β€œ032020”. Are you actually getting value β€œ-032020”?

In any case, if your filename is β€œ448473-032020.pdf”, and you only want β€œ032020”, assign a variable to:

System.Text.RegularExpressions.Regex.Match(MyStr, "(?<=-)\d+").Value

, where MyStr is your string β€œ448473-032020.pdf”.

1 Like

Thanks it worked

The date is saved on an excel sheet, just realised that the number format takes away the 0.

It’s all good now, thanks a lot

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.