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. Making a QString satisfy QRegularExpression
Forum Updated to NodeBB v4.3 + New Features

Making a QString satisfy QRegularExpression

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 849 Views 2 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.
  • M Offline
    M Offline
    ModelTech
    wrote on 21 Aug 2016, 08:49 last edited by ModelTech
    #1

    How can I check that a QString satisfies a regular expression in a QRegularExpression? I know this can be done for QLineEdit, but now the QString originates from a file and not from a user input. QString::contains seems insufficient here as I need a match...

    K 1 Reply Last reply 21 Aug 2016, 09:55
    0
    • M ModelTech
      21 Aug 2016, 08:49

      How can I check that a QString satisfies a regular expression in a QRegularExpression? I know this can be done for QLineEdit, but now the QString originates from a file and not from a user input. QString::contains seems insufficient here as I need a match...

      K Offline
      K Offline
      koahnig
      wrote on 21 Aug 2016, 09:55 last edited by
      #2

      @ModelTech

      There is an example for use of QRegularExpression available.
      I am using the older version QRegExp and its example. The example allows also to check externally of your code the regular expression string and its syntax with some text examples. The example code for QRegularExpression looks similar.

      There is another class QRegluarExpressionMatch

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JKSH
        Moderators
        wrote on 21 Aug 2016, 14:37 last edited by
        #3

        Hi @ModelTech,

        The methods you want are QRegularExpression::match() and QRegularExpressionMatch::hasMatch()

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply
        0
        • M Offline
          M Offline
          ModelTech
          wrote on 21 Aug 2016, 14:39 last edited by
          #4

          Thanks guys for these answers :)

          1 Reply Last reply
          0

          3/4

          21 Aug 2016, 14:37

          • Login

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