Help needed in string

I have a filename string which has no fixed format, but i know for sure that the last part of the string contains the version(before .XLSM), we are sure that there is an underscore before version “v” and .xlsm after version, and we want to extract only version from string, it could be v1, v2, v3 …v20 … example -
FY20Telstra_Budget_xyz_v1.xlsm, i want to extract only version (v1,v2…).how can i acheive this.
Pls advise.

Thanks

Hi,

Can you try the following expression?

strVersion =System.Text.RegularExpressions.Regex.Match(strFileName,"v\d+(?=\.xlsm)",RegexOptions.IgnoreCase).Value

Regards,

sorry but i didnt understand your solution. I am getting error as regexoperation is not declared.
pls advise
Thx

Hi,

How about the following?

strVersion =System.Text.RegularExpressions.Regex.Match(strFileName,"v\d+(?=\.xlsm)",System.Text.RegularExpressions.RegexOptions.IgnoreCase).Value

Regards,

1 Like

brilliant. Pure Magic!!!

Thanks a Zillion!!!

1 Like

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