Remove Parts of a String
-
wrote on 21 Feb 2019, 13:43 last edited by
Hello again,
im Looking to solve the fallowing, and i am Looking for ideas.
The string Looks like: Eintrag_2 { ExternalWritable := 'False'} : Bool;
and i want to remove { …} the curly bracket and everything between it. Does that just work with a parser or does the RegularExpressions have some Tools to do the Job?
-
Hello again,
im Looking to solve the fallowing, and i am Looking for ideas.
The string Looks like: Eintrag_2 { ExternalWritable := 'False'} : Bool;
and i want to remove { …} the curly bracket and everything between it. Does that just work with a parser or does the RegularExpressions have some Tools to do the Job?
wrote on 21 Feb 2019, 13:58 last edited byThis is depending on the complexity of text between curled braces. However, I would try first with QRegularExpression.
-
wrote on 22 Feb 2019, 09:03 last edited by
If someone wants to do the same, i did it with the fallowing Code:
int l_indexAnfang, l_indexEnde, l_deleteWeite;
l_indexAnfang = p_String.indexOf(QRegularExpression("{"),0);
l_indexEnde = p_String.indexOf(QRegularExpression("}"),0);
l_deleteWeite = l_indexEnde - l_indexAnfang + 1;
p_String = p_String.remove(l_indexAnfang, l_deleteWeite); -
wrote on 22 Feb 2019, 09:09 last edited by VRonin
p_String.replace(QRegularExpression(QStringLiteral("{.*}")),QString());
-
wrote on 22 Feb 2019, 10:28 last edited by meikelneit
Evene better. What is the Macro inside the Expression good for?
Does this just "create" the string while compiling so it hasnt to be created in the runtime anymore?
-
Evene better. What is the Macro inside the Expression good for?
Does this just "create" the string while compiling so it hasnt to be created in the runtime anymore?
wrote on 22 Feb 2019, 11:44 last edited by@meikelneit said in Remove Parts of a String:
Does this just "create" the string while compiling so it hasnt to be created in the runtime anymore?
-
wrote on 22 Feb 2019, 12:22 last edited by meikelneit
Thank you very mutch.
1/7