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
Qt 6.11 is out! See what's new in the release blog

[SOLVED] string endsWith in QML for url detection

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 2 Posters 6.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.
  • ? Offline
    ? Offline
    A Former User
    wrote on 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
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on 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>)) { ...}
        @

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          Thanks I'll try that

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            Well i gave that a try and works perfect

            thanks for your help

            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