Strings fields *,?
-
Hi! If i understand you correctly, you can use "QRegExp":http://qt-project.org/doc/qt-4.8/qregexp.html
-
It does not matter whether a string contains a filename or a sentence, the principle is the same.
There are plenty of regular expression tutorials around with examples and all. Just use google. RegExps are something that should be in every programmers toolbox, so learning about them will not be a waste of time!
-
Hi all...I used this..but not working...tried some others like * , \W* etc
@QString str="my name is dave";
QRegExp rx("my name is [^ ]*");
rx.setPatternSyntax(QRegExp::Wildcard);
int pos = 0;
while ((pos = rx.indexIn(str, pos)) != -1) {
qDebug()<< rx.capturedTexts();qDebug() << rx.cap(1);
pos += rx.matchedLength();
}
@
Whats wrong...Please help -
Hi,
AFAIK, you don't use a capturing RegExp, you have to use parenthesis to capture something. Take a look at the QRegExp doc, specially the "capturing text part":http://qt-project.org/doc/qt-4.8/qregexp.html#capturing-text
-
the string read from the file is below
reject tcp any any -> any any (content:"twitter.com";msg:"TWITTER1 BEING ACESSED";sid:41325;rev:001;)
[CODE]
QRegExp re("(\w*) tcp (\w*) any -> any any \(content:(("([A-Za-z0-9_\./\-$\s])"));msg:(("([A-Za-z0-9_\./\-$\s])"));sid:(\w*);");while((pos=re.indexIn(str, pos))!=-1){
list << re.cap(1);//gives first field from string list << re.cap(2);//gives 3rd field list << re.cap(3);//gives content list << re.cap(6);//gives msg list << re.cap(9);//gives sid pos+=re.matchedLength(); }
[/CODE]
The above regex gives me reject, any, twitter.com, twitter being accessed, 41325
but for that i have to choose 1,2,3,6,9 fields out of the re.cap coz the line has multiple line of quotes.but the same doesn't work for the below string
alert tcp 192.168.1.9 any -> any any (content:"www.gmail.com";msg:"gmail being ACCESSED";sid:41330;rev:001;)please help