You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

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