正規表現に問題があります。
文字列があると考えてください
S= "[sometext1],[sometext],[sometext]....,[sometext]"
「sometexts」の数は不明であり、ユーザーの入力であり、1から..たとえば1000まで変化する可能性があります。
[sometext]は文字のシーケンスですが、それぞれが "、"ではないため、[^、]と言うことができます。
正規表現でテキストをキャプチャしてから、テキストを繰り返し処理したいと思います。
QRegExp p=new QRegExp("???");
p.exactMatch(S);
for(int i=1;i<=p.captureCount;i++)
{
SomeFunction(p.cap(i));
}
たとえば、一部のテキストの数が3の場合、次のように使用できます。
([^,]*),([^,]*),([^,]*).
So,i don't know what to write instead of "???" for any arbitrary n.
I'm using Qt 4.7,I didn't find how to do this on the class reference page.
I know we can do it through the cycles without regexps or to generate the regex itself in cycle,but these solutions don't fit me because the actual problem is a bit more complex than this..