Unsolved Select a substring in QString
-
I have a string like "//Machine/C://DriveOne/File1". I wanted to select this part "DriveOne/File1" from that string. How can I do that? I have defined these strings a QString.
-
@Azadshahr
Before anyone answers this, are you sure about theC://
bit? Sure it isn't://Machine/C:/DriveOne/File1"
?
-
Yeah. It is "//Machine/C:/DriveOne/File1" correct. Sorry. However, I wanted to select "DriveOne/File1".
-
Simply split the string at "//" maybe?
-
@Azadshahr
I suspected so :) I asked because now looking for//
isn't going to help you.So you can either split at/index from
:/
, or useQRegularExpression
depending on just what you want to allow for. -
@JonB said in Select a substring in QString:
I asked because now looking for // isn't going to help you.
Why not? Simply split, take the last one.
-
@Christian-Ehrlicher
Have you seen that the OP confirmed the string is://Machine/C:/DriveOne/File1
Not as originally posted; there is no longer
//
in the middle. And he wants back:DriveOne/File1
Which is why I said split on
:/
. -
@JonB Ah, sorry - but the logic is the same :)