2

This is weird, I have the following std::regex (rx)

\{\{alternate form of\s*\|(?:\d=)?(.*?)([\|#][^\|}]*)*\}\}

which regex_search returns true for when given this string (str)

{{alternate form of|abate|nodot=1}} {{qualifier|abbot}}.

but when I call regex_match(str, m, rx), the match set m is empty. Using JavaScript mode in RegexBuddy (which seems to be the closest in behaviour I can find to VS2012's regex support) the matches are correctly found. Anyone got any ideas? The regex looks overspecified because some other strings need extra pieces matched...

1 Answer 1

1

regex_search matches any part of the target string. regex_match matches the entire string. The regular expression matches the first part of the target string, "{{alternate form of|abate|nodot=1}}". That's what regex_search finds. That's not the entire string, which is why regex_match doesn't find a match.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.