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. QRegExp, perl and Unicode
Forum Updated to NodeBB v4.3 + New Features

QRegExp, perl and Unicode

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 3.1k 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.
  • D Offline
    D Offline
    dcortesi
    wrote on 27 Jul 2011, 00:06 last edited by
    #1

    According to the "documentation for QRegExp":http://developer.qt.nokia.com/doc/qt-4.7/qregexp.html, it "is modeled on Perl's regexp language. It fully supports Unicode."

    However, Perl's regexp ("documented here":http://perldoc.perl.org/perlre.html) specifies support for the special escape \N{name} to match a named Unicode character or character sequence, e.g. \N{KELVIN SIGN},

    and also for \p{property} and \P{property} to match or not-match numerous Unicode properties "listed here":http://perldoc.perl.org/perluniprops.html#Properties-accessible-through-\p{}-and-\P{}.

    I do not see either \p or \N mentioned in the QRegExp doc page. Are they there but not documented? Are these features (named characters and properties) supported in some other way?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on 27 Jul 2011, 07:18 last edited by
      #2

      Is modeled on doe not mean is equal :-)
      Afaik it only handles the syntax that is written in the docs, so I assume it can't handle those two types.

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dangelog
        wrote on 27 Jul 2011, 08:37 last edited by
        #3

        No. They're simply not there. QRegExp supports a (minimal) subset of Perl's regexps, and it's not even PCRE compatible (f.i. there are no non-greedy operators).

        You can work around the lack of \N support by (sigh...) using \x. Unfortunately not only there's no direct equivalent of the \p escape, but the information provided by QChar are not enough to provide a workaround.

        The best I can suggest is to dump QRegExp and using libpcre to do your matches.

        Software Engineer
        KDAB (UK) Ltd., a KDAB Group company

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dcortesi
          wrote on 27 Jul 2011, 13:56 last edited by
          #4

          Because I'm working in PyQt, libpcre is not available. Python native re support also lacks \p\N and has other Unicode deficiencies. However there is a good extension regex package ("regex":http://pypi.python.org/pypi/regex) with rather complete Unicode support.

          The difficulty that I see as a [Py]Qt newbie is in working on the one hand with a QPlainTextEditor and text cursor objects, and on the other with Python-based regex matching. Constantly crossing between the world of the editor document and the world of Python u"strings" looks like a very fruitful way to create confusion and mistakes. Comment?

          1 Reply Last reply
          0

          1/4

          27 Jul 2011, 00:06

          • Login

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