regex - Regular Expression Matching all permutations -


i want find permutations of 0123 in string below 01210210021212333212300213231102023103130001332121230221000012333333021032112

can have regular expression can give me permutations of 0123 matching in string ? need if there overlapped patters

"0123" here want match of [1023][1230][2301][3012]

not regex, c++11:

#include <iostream> #include <algorithm> #include <string>  int main() {     const std::string s("01210210021212333212300213231102023103130001332121230221000012333333021032112");     const std::string ref("0123");      if(ref.length() > s.length())     {         return 0;     }      for(int = 0; < s.length() - ref.length(); ++i)     {         if(std::is_permutation(s.cbegin()+i, s.cbegin()+i+ref.length(), ref.cbegin()))         {             const std::string extract(s, i, ref.length());             std::cout << extract << std::endl;         }     }     return 0; } 

to compiled example g++ -std=c++11 -o sample sample.cpp

if absolutely need regex: (?=[0123]{3})(.)(?!\1)(.)(?!\1|\2)(.)(?!\1|\2|\3). means:

(?=[0123]{3}) : positive assertion 4 next characters 0, 1, 2, 3 (.) : capture first character (?!\1) : assert following character not first capture group (.) : capture second character (?!\1|\2) : assert following character neither first nor second capture group etc. 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -