Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
Say I have a string:
std::string x = "\\asdasd\\sewef\\sdvrhe\\"
How do I remove the double backslahes so that the string only contains single backslahes?
I need x string's value to be:
\asdasd\sewef\sdvrhe\
I am open to replacing chars or removing any method that achieves the desired result will be accepted.
"boost string algo" is your friend:
boost::replace_all(x, "\\\\", "\\");
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Hello I am using c++ for this assignment.
If I have a string such as "P10" and I want to store the number 10 into an integer disregarding the P, how would I do that?
Assuming you only want to remove the first character from your string then
#include <string>
std::string str = "P10";
int i = std::stoi(str.substr(1));
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have a string stored in a variable - "Input_value:123_Output".
I want to split this string with underscore(_) and Double colon(:). So that the indexing of my output string will be like this : [0]-Input, [1]-value, [2]-123, [3]-Output.
Thanks!
Try splitting on the regex character class [:-]. This would split on either a colon or an underscore, which is the behavior you want.
In addition to [:-] looking like a smiley face, it is also very compact and easy to read.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have a string which has a hastag/pound/octothorpe in it, and want it removed using a regex expression.
e.g.
iii <- '#lkdjljf, lkdflsdkf'
i would like a gsub(regex_bit_here,'',iii)
to remove the hastag/pound/octothorpe
Thanks
I have triedgsub("^#",'',iii), and it works
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
In Perl, I would like to determine if a given string is valid, the rule is to check if values exist between commas.
e.g. abc,abc is a valid case, but abc, or abc,,abc are not.
m/^\s*,|,\s*,|,\s*$/
matches all invalid combinations, assuming whitespace does not count as "values".
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
How to parse a string using boost::spirit excluding defined substrings?
For example, a string must not contain $lf, $pt, $kf
You may mean
*(qi::char_ - (qi::lit("$if") | qi::lit("$pt") | qi::lit("$kf"))