Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Use regex within C++ program

Use regex within C++ program

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 2.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Esperion
    wrote on last edited by
    #1

    Hello to all,

    I have to add a GUI to a C++ program that I'm working on. I'm trying to use regex in the C++ program, but I've found
    that only Microsoft Visual Studio 2012 compiler supports Regex for C++.

    Should I do the C++ code in MSVisual Studio and once finish use my C++ source code to add the GUI in Qt or how can I do?

    Thanks in advance for the answer.

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      Qt Qt Evellyn
      wrote on last edited by
      #2

      You can use the QRegExp class!
      And by using it, you gain portability at no extra cost! =D

      Evellyn 【ツ】

      1 Reply Last reply
      0
      • E Offline
        E Offline
        Esperion
        wrote on last edited by
        #3

        Hello Evellyn,

        Thanks for your answer.

        I'm new to Qt and I'd like to know if having my current C++ code I can do something like below:

        My code looks like this and whithin while loop is where I need to a call to a function to parse a string using regex .

        So, can I include the QRegExp code inside my C++ code or the QRegExp code should go in another file and I need to call QRegExp function from C++ code? if yes, how?

        @#include <iostream>
        .
        .
        function1 ()
        //My original C++ code

        function2 (){
        //My original C++ code
        }

        My_RegexFunction(Input) {
        // Qt QRegExp code

        }

        int main () {
        .
        ..
        //My original C++ code

        while () {

        Myvar=My_RegexFunction(Input);
        }
        }@

        Thanks in advance for the help.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You can use QRegExp directly in your code, have a look "at the documentation":http://qt-project.org/doc/qt-4.8/qregexp.html#details to see how to use it.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #5

            if you use Qt 5 i would suggest to use "QRegularExpression":http://qt-project.org/doc/qt-5.0/qtcore/qregularexpression.html rather than QRegExp.
            Since QRegExp is buggy and not complete and not maintained anymore.
            QRegularExpression in contrary is a implementation of full Perl-compatible regular expressions in Qt.

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • E Offline
              E Offline
              Esperion
              wrote on last edited by
              #6

              Hello SGaist and raven-worx,

              Thank you for your answers. I'll check the options you suggest me.

              Best regards

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved