User account creation filtered due to spam.

Bug 61859 - extra character in match of std::regex_match
Summary: extra character in match of std::regex_match
Status: RESOLVED DUPLICATE of bug 53631
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2014-07-20 20:17 UTC by Pavol Rusnak
Modified: 2014-07-20 23:16 UTC (History)
0 users

See Also:
Known to work:
Known to fail:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Pavol Rusnak 2014-07-20 20:17:40 UTC

// g++ ./regex_test.cpp -std=c++11 -o ./regex_test && ./regex_test

#include <iostream>
#include <string>
#include <regex>

int main()
	std::string s = "/call/123";
	std::regex r = std::regex("/call/(.+)");
	std::smatch mr;
	bool m = std::regex_match(s, mr, r);

	std::cout << m << std::endl;     // prints 1, OK
	std::cout << mr[0] << std::endl; // prints "/call/123", OK
	std::cout << mr[1] << std::endl; // prints "/123", expected "123"

	return 0;
Comment 1 Jonathan Wakely 2014-07-20 23:16:46 UTC
<regex> is not implemented in gcc 4.8

why are you even using gcc 4.8.0? at least use 4.8.3, or 4.9.1 if you want <regex>

*** This bug has been marked as a duplicate of bug 53631 ***