c++正則表達式

#include <regex>
void GetValueFromFilesName(std::string s, float &x, float &z, float &angle)
{
	std::vector<std::string> str;

	std::smatch sm;
	s.erase(s.size() - 4, s.size() - 1);

	std::regex re("[-0-9.]+[0-9]+[0-9]");
	for (int i = 1; i <= 5; ++i)
	{
		if (std::regex_search(s.cbegin(), s.cend(), sm, re))
		{
			str.push_back(sm.str());
			s = sm.suffix().str();
		}
	}

	_atoflt((_CRT_FLOAT*)&x, str[1].c_str());
	_atoflt((_CRT_FLOAT*)&z, str[3].c_str());
	_atoflt((_CRT_FLOAT*)&angle, str[4].c_str());
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章