Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [SOLVED] string endsWith in QML for url detection
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] string endsWith in QML for url detection

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 2 Posters 5.0k 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.
  • A Offline
    A Offline
    Alcatraz
    wrote on 13 Jun 2012, 20:26 last edited by
    #1

    i have tried to take a string like var urlString = http://rss.cbc.ca/lineup/canada.xml

    how am i able to see if the urlString endsWith ".xml"

    1 Reply Last reply
    0
    • M Offline
      M Offline
      miroslav
      wrote on 14 Jun 2012, 05:43 last edited by
      #2

      This should do: http://qt-project.org/doc/qt-4.8/qstring.html#endsWith

      Mirko Boehm | mirko@kde.org | KDE e.V.
      FSFE Fellow
      Qt Certified Specialist

      1 Reply Last reply
      0
      • M Offline
        M Offline
        miroslav
        wrote on 14 Jun 2012, 05:53 last edited by
        #3

        Actually, forget what I just said :-) Sorry. I think from within JS, you need to use regular expressions:

        @
        var endsWithXml = /xml$/;
        if (endsWithXml.test(<filename>)) { ...}
        @

        Mirko Boehm | mirko@kde.org | KDE e.V.
        FSFE Fellow
        Qt Certified Specialist

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Alcatraz
          wrote on 14 Jun 2012, 13:57 last edited by
          #4

          Thanks I'll try that

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Alcatraz
            wrote on 14 Jun 2012, 15:30 last edited by
            #5

            Well i gave that a try and works perfect

            thanks for your help

            1 Reply Last reply
            0

            5/5

            14 Jun 2012, 15:30

            • Login

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