0

I need to evaluate a regex on some data that I have. It is to get filenames from a string input in a specific order.

I have so far done this - http://regex101.com/r/rZ8tP0/1

PS: I am not well versed with regex, so kindly do not talk about this being non-optimal. Optimal solutions welcome.

The real issue is - I have a C++ program that does this. The program returns a 0 for the same string-regex combination, for which regex101 returns 1. What am I missing?

The C++ code is:

#include<iostream>
#include<regex>
using namespace std;
int main()
{
    string s = "data-FileName-author-data-";
    string r = "(.+-){1}FileName-(.+-){2}";
    cout<<regex_match(s, regex(r))<<"\n"; //returns 0
}                 
Kut KV
  • 15
  • 3

1 Answers1

1

Which compiler you use? If gcc - only gcc 4.9+ supports correct work for regexes. Live example on Coliru, that shows 1

ForEveR
  • 55,233
  • 2
  • 119
  • 133