❔ What would be the best way to dynamicly cut in a string>
So for example I have this:
"C:\Users\USERNAME\Documents\Paradox Interactive\Hearts of Iron IV\mod\HoI4-LotrMod\gfx\interface\goals\Generic\GFX_goal_generic_industry_I.tga"
But Im only intrested in the location of the file within the folder "HoI4-LotrMod" altough that folder could in theory be called anything.
What would be the best way to make sure I would always end up with the last "gfx\interface\goals\Generic\GFX_goal_generic_industry_I.tga" part
6 Replies
Hope my qustion is clear this way 😅
Split on
"HoI4-LotrMod"
and take the last part?Angius
REPL Result: Success
Result: string
Compile: 512.539ms | Execution: 38.347ms | React with ❌ to remove this embed.
I would probably use IndexOf and Substring but that's arguably a matter of personal preference. I kind of have a personal dislike of the Split method because it often allocates a bunch of strings you don't care about. (Of course, now we're micro-optimizing.)
Alright thanks
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.