You are not logged in.

simonb

Beginner

  • "simonb" is male
  • "simonb" started this thread

Posts: 28

Location: Jerusalem,Israel

  • Send private message

1

Sunday, August 7th 2011, 3:23pm

Capture string using QRegex

Hi,
I'm tring to capture sub string with QRexex without success.
For example:
I need to capture the string "*AAA33A" from the string "*FF12FFF FF11 *AAA33A"
I tried:
QRegExp rx("^\\*[0-9A-F]\\*");
QString invalidStr = rx.cap(1);

help please...thx

bst

Beginner

  • "bst" is male

Posts: 42

Location: Germany

  • Send private message

2

Monday, August 8th 2011, 8:52am

Hi,

Source code

1
2
3
4
   QString str("*FF12FFF FF11 *AAA33A*");
   QRegExp rx("\\*[0-9A-Z]+\\*");
   if (rx.indexIn(str, 0) != -1)
      qDebug() << rx.cap(0);

or

Source code

1
2
3
4
   QString str("*FF12FFF FF11 *AAA33A*");
   QRegExp rx("\\*([0-9A-Z]+)\\*");
   if (rx.indexIn(str, 0) != -1)
      qDebug() << rx.cap(1);

maybe?

HTH, Bernd

simonb

Beginner

  • "simonb" is male
  • "simonb" started this thread

Posts: 28

Location: Jerusalem,Israel

  • Send private message

3

Monday, August 8th 2011, 12:48pm

thanx for the reply
It dosen't worked

simonb

Beginner

  • "simonb" is male
  • "simonb" started this thread

Posts: 28

Location: Jerusalem,Israel

  • Send private message

4

Monday, August 8th 2011, 1:32pm

I found anouther solution thanxs anyway