Skip to content

Instantly share code, notes, and snippets.

@utilForever
Created March 27, 2019 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save utilForever/2bb897942e0e632747c5cb5c2f7ff14a to your computer and use it in GitHub Desktop.
Save utilForever/2bb897942e0e632747c5cb5c2f7ff14a to your computer and use it in GitHub Desktop.
Regex test
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <regex>
int main()
{
std::regex attackRegex("\\+([[:digit:]]+) Attack");
std::string text = "Raid Leader is granting this minion +1 Attack";
std::smatch values;
if (std::regex_search(text, values, attackRegex))
{
std::cout << values[1].str().c_str() << '\n';
}
else
{
std::cout << "Not found\n";
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment