0

0 と 1 の文字列シーケンスがあるため、複数の位置で複数の部分文字列に一致する正規表現を作成する必要があります。

Example:
string sequence: "001100110111100010100101000011111010"
substring1: "1100"  position1: 2
substring2: "10"    position2: 3
substring3: "10001" position3: 12

指定されたすべての位置ですべての部分文字列が一致する場合、true または false を返す必要があります。

そのような正規表現を C++ で書くことは可能ですか?

ご協力いただきありがとうございます。

4

1 に答える 1

0
const char * sequence = "001100110111100010100101000011111010";       
boost::regex e("??1100??????10001");
bool all_present = boost::regex_match ( sequence, e );

2 番目の方法:

  const char * sequence = "001100110111100010100101000011111010";       
  boost::regex exp1("1100");
  boost::regex exp2("10");
  boost::regex exp3("10001");

  bool all_present = boost::regex_match ( sequence, sequence + 2, exp1) &&  
                     boost::regex_match ( sequence, sequence + 3, exp2) &&
                     boost::regex_match ( sequence, sequence + 12, exp3);
于 2013-11-04T10:15:32.950 に答える