Dissect a String

In VS 2015 Windows Form I'm parsing a text file trying to extract the file name contained in a call. I identify the call string...

15 - CALL Sub873 ;

run this code...

array<Char>^ allThis = { L' ', ';' };
int index;
String^ file = String::Concat((curLine->Substring(index + 6))->Trim(allThis), ".DT");

and get Sub873.DT (desired file name)

I've been unsuccessful to extract the file name from the string variant where arguments are included in the string enclosed in brackets().

15 - CALL Sub873(1700,-1000) ;

With old C++ I would just STRSTR to '(' and add an EOL char essentially truncate the string at (

I've tried TrimEnd("(") with no luck. How should I go about this? Is the a better all around method or function?

Well, you knew about strstr()...

Googling "C# equivalent of strstr" took me here:
http://stackoverflow.com/questions/12734174/what-is-the-c-sharp-equivalent-to-strstr-in-c

which tells me... string.IndexOf()

But the variable index is uninitialized in your code, so how does it work??

Andy

As you're writing in C++/CLI rather that C++ you'll find C# docs helpful, as there more of them about than C++/CLI. Just need to massage the syntax a bit.
Last edited on
Topic archived. No new replies allowed.