Linked Questions

0 votes
1 answer
471 views

Im trying to learn how I could write a regex evaluator in c++ with lambda expression 5;4 11;2 7;3 inputx.gsub(/(.*?);(.*?)\n/) { ($1.to_i - $2.to_i ).to_s + "\n" } 1 9 4 How I could do this if ...
alberto's user avatar
  • 49
20 votes
2 answers
49k views

I am trying to replace certain patterns in a string with different replacement patters. Example: string test = "test replacing \"these characters\""; What I want to do is replace all ' ' with '_' ...
pstrjds's user avatar
  • 17.6k
1 vote
2 answers
2k views

I want to selectively replace the (") doublequotes in a C++ std::string. i.e. i want to replace all occurences of (") doublequotes in a string except the 1st and last occurence of (") doublequotes in ...
codeLover's user avatar
  • 3,860
4 votes
2 answers
2k views

I find this regex for replacement Regex replace uppercase with lowercase letters Find: (\w) Replace With: \L$1 My code string s = "ABC"; cout << std::regex_replace(s, std::regex("(\\w)"), "\\...
Zhang's user avatar
  • 3,406
0 votes
2 answers
1k views

Suppose my string is "g500() g600() g200()\n g1()" I want to output "g1() g2() g3()\n g4()" instead. I have tried using regex to do it like so, but this gives each occurence the same value. #...
Hisham Hijjawi's user avatar
2 votes
3 answers
404 views

I have a "custom" string that has the following format. Example: std::string MyString = "RndOrder%5d - RndCustomer%8s - RndHex%8x"; I would like to replace/parse the string: the %5d (%NUM_d) would be ...
raff's user avatar
  • 378
6 votes
3 answers
203 views

I want to catch numbers appearing anywhere in a string, and replace them with "(.+)". But I want to catch only those numbers which have an even number of %s preceding them. No worries if any ...
AneesAhmed777's user avatar
0 votes
2 answers
523 views

I'm trying to find a way to simplify the comparison cases of booleans. Currently, there are only three (as shown below), but I'm about to add a 4th option and this is getting very tedious. ...
ZeldaZach's user avatar
  • 538
0 votes
3 answers
558 views

I am having ridiculous difficulties matching a regex and replacing the match with another string. I want to achieve this with iterators, as outlined below. The part that does not work is getting ...
user52366's user avatar
  • 1,167
2 votes
1 answer
624 views

I am using std::regex and need to do a search and replace. The string I have is: begin foo even spaces and maybe new line( some text only replace foo foo bar foo, keep the rest ) some more text not ...
Mathias's user avatar
  • 1,506
0 votes
1 answer
281 views

I would like to find $number substrings and then replace them with $number + 1 format. For example, $1 should become $2 in a string. So far, I found out how to find $number pattern in a string and ...
Zack Lee's user avatar
  • 3,154
0 votes
1 answer
162 views

I'm trying to learn using regex in C++ and I got this code: std::string s("21\n"); std::regex e("\\b(2)1"); std::cout << std::regex_replace(s, e, "${1}0 first"); I wanna turn 21 into ...
Aleksandr's user avatar
0 votes
1 answer
283 views

In Perl, I can replace characters with their lowercase version like so: my $str = "HELLO WORLD HOW ARE YOU TODAY"; $str =~ s/([AEIOU])/\L\1/g; print $str; # HeLLo WoRLD HoW aRe You ToDaY"; How can I ...
Lightness Races in Orbit's user avatar
3 votes
2 answers
107 views

I'm very new to regex and C++, so please be easy on me :) ! Given a string like this one: Input: string s = "<ph0/>Hello StackOverflow! Thank you for helping! <ph1/>" I want to replace ...
José Rodrigues's user avatar
1 vote
0 answers
77 views

I am reading/modifying an XML file line by line, and I run into some problems when trying to identify some variables. For example, I have two lines: I have the following regex ...
masshakar's user avatar