mercredi 24 février 2016

Regex skip in C++

This is my string:

/*
  Block1 {

    anythinghere
  }
*/

// Block2 { }
# Block3 { }

Block4 {

    anything here
}

I am using this regex to get each block name and inside content.

regex e(R"~((\w+)\s+\{([^}]+)\})~", std::regex::optimize);

But this regex gets all inside of description too. There is a “skip” option in PHP that you can use to skip all descriptions.

What_I_want_to_avoid(*SKIP)(*FAIL)|What_I_want_to_match

But this is C++ and I cannot use this skip method. What should I do to skip all descriptions and just get Block4 in C++ regex?

This regex detects Block1, Block2, Block3 and Block4 but I want to skip Block1, Block2, Block3 and just get Block4 (skip descriptions). How do I have to edit my regex to get just Block4 (everything outside the descriptions)?

Aucun commentaire:

Enregistrer un commentaire