Community
    • Login

    Escaping delimiters does not work with UDL.

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 801 Views 2 Watching
    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.
    • Manish PatelM Offline
      Manish Patel
      last edited by PeterJones

      I have a customized UDL set up for ActionScript 3, wherein I use double quote (") as delimiters for Strings. I have also included the escape character (\). However, when my code contains Regular Expressions like !/^\/[^\"]*$/, the escape character does not escape the double quote and the entire code after this is styled with the String styler.

      In userDefineLang.xml it appears as <Keywords name="Delimiters">00&quot; 01\ 02&quot; 03&apos; 04\ 05&apos; 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23</Keywords> which seems correct to me.

      Can anyone help me figure this out? Thanks.

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP Offline
        PeterJones @Manish Patel
        last edited by PeterJones

        @Manish-Patel,

        Based on your description, I assume you are seeing something akin to
        e28deaed-860a-4b30-9409-669bbcf0badd-image.png
        … where the regex starts looking like a quote starts inside.

        In that example, I also showed examples of how the escape is actually intentended to work: the “Escape” character escapes the various open/close symbols _when embedded between open/close symbols. So "In \" quotes", it properly treats the \" as being inside the string, not ending the string, and similarly for the single-quote example.

        Since, based on your <Keywords...> line, you don’t have regex defined as delimiters, the parser is not in a mode where it knows it needs to escape them.

        If you define regex wrappers as delimiters as well, like:
        c4459c06-30a2-4102-b735-97449b2d96f2-image.png

        … then you can get it to treat the regex as a string:
        9c3810c4-bef3-4bb0-b24e-9443e312a000-image.png

        The reason the quote isn’t starting a string inside the regex is because, by default, UDL doesn’t allow nesting of delimiters, unless you tell it to in the Stylers. This is more obvious if I do the same regex, but with the quotes not escaped:
        186dddd5-94e5-4595-a12f-d3b85b0f2d2b-image.png

        The quotes are still not treated as string-starters, because the regex delimiters were not defined to allow nesting of the string delimiters.

        On the other hand, if you define Delimiter 5 to be [ and \ and ] and then in the Styler definition you also allow nesting of Delimiters 1 and 2:
        f6821207-5207-450b-98b9-5168b42c7068-image.png

        … then you can get another example, which shows quotes embedded in brackets, and escaped brackets:
        347cbe63-ed9c-482b-8cbd-97498d8cc7f3-image.png

        If you escape the quotes when inside brackets, they will not be recognized as embedded quotes anymore:
        8ec9e14d-4e2d-48fe-848b-4b5bf5931cd6-image.png

        So I believe these are the kinds of setups you will want. Defining the regex wrappers as delimiters as well should go a long way to giving you what you want, I think.

        1 Reply Last reply Reply Quote 2

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors