Substring Get Value

“C:\Users\abk\OneDrive - Amss\Documents\test file\5743939.csv” how to get 5743949 from this above file path

HI @Abhirami_Ashok_Kumar

Try with this expression

Path.GetFileNameWithoutExtension("C:\Users\abk\OneDrive - Amss\Documents\test file\5743939.csv")

Regards
Gokul

2 Likes

@Abhirami_Ashok_Kumar

Rgex for this (\d+)\.csv
System.Text.RegularExpressions.Regex.Matches(yourstringinput.ToString,“(\d+)\.csv”)
1 Like

Hi @Abhirami_Ashok_Kumar

Use the regex expression to extract the output. Please find the below regex expression.

System.Text.RegularExpressions.Regex.Matches(yourstringinput.ToString,“(\d+(?=.csv))”)

Hope it helps!!

1 Like

Hi @Abhirami_Ashok_Kumar
Try this

Regards,

1 Like

Hi @Abhirami_Ashok_Kumar

I think so you’re trying to get the FileName so it would be a better option to use.

fileName= Path.GetFileNameWithoutExtension(PathVariable)

This would be returning, you the filename irrespective of whether its number or characters.

1 Like