int main()
{
// Get line length until ';' character with regex
std::wstring line = L"string 1 ; string 2";
unsigned linelength = 0;
if (!line.starts_with(L";"))
{
std::wregex reg(L";");
std::wsmatch match;
if (std::regex_match(line, match, reg))
{
const std::ptrdiff_t len = match.position();
linelength = len > linelength ? len : linelength;
}
std::cout << linelength;
}
}
I know I could use std::size_t pos = line.find(L';');
But this is just an example of larger portion, I need it with regex.
Basically I need line length excluding anything beyond and including ";"
**EDIT:**
I figured out that I need to use std::regex_search instead.