Forum Discussion

TestQA1's avatar
TestQA1
Frequent Contributor
2 years ago
Solved

Getting a substring in a variable out of Project FileName

Hi All,

 

I have a fully qualified file name of my project.

 

var bb = C:\\Testing\BDD\ABC072_SDS\ABC072_SDS.mds 

 

I need to get 'ABC072_SDS' from the path and store in a variable to use it further.

 

How can I use regex to get the required text?

 

Because 072 is always changing with different project names, I cannot give it as substring. I am looking for a solution that takes the whole ABC072_SDS out without worrying about the digits 072.

 

Thank you.

  • Hi,

     

    I hope that aqFileSystem.GetFileNameWithoutExtension() is what you are looking for.

     

2 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    I hope that aqFileSystem.GetFileNameWithoutExtension() is what you are looking for.

     

  • TestQA1's avatar
    TestQA1
    Frequent Contributor

    Found this method. 

     

    var t = Project.FileName;
    Log.Message(aqString.SubString(t, 57, 12)); seems to work but don't know if there is something better as here we are counting the index and it may break if the path changes.