HISE Logo Forum
    • Categories
    • Register
    • Login

    Identifying Characters in a String?

    Scheduled Pinned Locked Moved Scripting
    4 Posts 2 Posters 213 Views
    Loading More Posts
    • 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.
    • CasmatC
      Casmat
      last edited by

      Hey!

      I have a label in my project that renames a file, I have put a button below to submit the text in the label. I put a if statement to check the text for unsupported characters in file naming: \ / : * ? " < > |. I thought of making the if statement check the string using the contains() function and putting the characters above into the parentheses of that function. However, the characters don't really play nice when I tried putting them in the parentheses! any ideas? Thanks again!

      i make music

      1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey
        last edited by

        Yeah you're going to run into issues using quotes and slashes because they have specific uses within a string.

        You probably should use one of the regex functions. ChatGPT will help with regex, also this site - https://regex101.com/

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        CasmatC 2 Replies Last reply Reply Quote 0
        • CasmatC
          Casmat @d.healey
          last edited by Casmat

          @d-healey the regular escapes won't work with hise due to the syntax, but the unicode escape and hexadecimal escape doesn't work as well? I tried using the Engine.matchesRegex() function inputting the regex string as "\u005C|\u002F|\u003A|\u002A|\u003F|\u0022|\u003C|\u003E|\u007C" for unicode and "\x5C|\x2F|\x3A|\x2A|\x3F|\x22|\x3C|\x3E|\x7C" in hex format

          i make music

          1 Reply Last reply Reply Quote 0
          • CasmatC
            Casmat @d.healey
            last edited by

            @d-healey haha! got it to work, i love using regex! "\\x5C|\\x2F|\\x3A|\\x2A|\\x3F|\\x22|\\x3C|\\x3E|\\x7C"

            i make music

            1 Reply Last reply Reply Quote 1
            • First post
              Last post

            29

            Online

            1.8k

            Users

            12.0k

            Topics

            104.6k

            Posts