jeudi 5 juillet 2018

c++ regex not working as expected (regex_search)

I currently am working on regex in c++ in which I tried to search a substring in a string.

Problem :

String :

<Directory />
AllowOverride none
Require all denied
</Directory>

<Directory "C:/xampp/htdocs/dashboard">
Options +Indexes
AllowOverride None
Require all granted
</Directory>

In this I need only the first Directory contents,that is

<Directory />
AllowOverride none
Require all denied
</Directory>

Hence I used the regex

Regex : < *Directory *\/? *>(\n.*?)+<\/Directory>

In this regex I used a \n.*? so that it will return the first result(lazy). It works fine when I tried in https://regexr.com but when I use regex_search it shows there isn't a match. How is this possible? Am I missing out anything?

Aucun commentaire:

Enregistrer un commentaire