Loading ...
Sorry, an error occurred while loading the content.

matching the last part of a url

Expand Messages
  • Eric Smith
    I am not managing to crack this for a syntax highlight rile. http|www.foo.bar/baz/baz - I want to match baz http|www.foo.bar/baz/baz/ - I want to
    Message 1 of 4 , May 23 7:10 AM
    • 0 Attachment
      I am not managing to crack this for a syntax highlight rile.

      http|www.foo.bar/baz/baz -> I want to match baz
      http|www.foo.bar/baz/baz/ -> I want to match baz/
      http|www.foo.bar/baz/baz/biz -> I want to match biz

      Thanks for any solution.

      Eric

      --
      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/d/optout.
    • Tim Chase
      ... Your http| is a little odd (I d normally expect https =:// , but if that s actually what you have, you should be able to do something like
      Message 2 of 4 , May 23 9:32 AM
      • 0 Attachment
        On 2014-05-23 16:10, Eric Smith wrote:
        > http|www.foo.bar/baz/baz -> I want to match baz
        > http|www.foo.bar/baz/baz/ -> I want to match baz/
        > http|www.foo.bar/baz/baz/biz -> I want to match biz

        Your "http|" is a little odd (I'd normally expect "https\=://", but if
        that's actually what you have, you should be able to do something like

        \(http|\S*\/\)\@<=\w\+\/\=\S\@!

        It's a little sloppy, as it assumes that the results you want to find
        match "\w\+" while other characters could legitimately be there.
        But that should give you the foundation for improving it.

        It roughly translates to

        \(
        http|\S*\/
        \)\@>= assert that the stuff preceding this is contextually a URL
        \w\+ the pattern we actually want
        \/\= optionally a trailing slash
        \S\@! assert that a non-whitespace doesn't follow the slash

        -tim


        --
        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/d/optout.
      • Eric Smith
        Tim Chase wrote on Fri-23-May 14 6:32PM ... Thanks Tim, this works perfectly when tested with matchstr(), however I need ti in a syntax file and there it
        Message 3 of 4 , May 23 2:59 PM
        • 0 Attachment
          Tim Chase wrote on Fri-23-May 14 6:32PM
          > \(http|\S*\/\)\@<=\w\+\/\=\S\@!

          Thanks Tim, this works perfectly when tested with matchstr(),
          however I need ti in a syntax file and there it appears to be a
          noop. I tried;
          syn match last_url '\(http\S*\/\)\@<=\w\+\/\=\S\@!'

          Any ideas?

          --
          Eric Smith

          --
          --
          You received this message from the "vim_use" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php

          ---
          You received this message because you are subscribed to the Google Groups "vim_use" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          For more options, visit https://groups.google.com/d/optout.
        • Charles Campbell
          ... It should work perfectly as is in a syntax file, too. I suspect that you have some syntax priority issues going on. * later syntax takes priority over
          Message 4 of 4 , May 27 7:18 AM
          • 0 Attachment
            Eric Smith wrote:
            > Tim Chase wrote on Fri-23-May 14 6:32PM
            >> \(http|\S*\/\)\@<=\w\+\/\=\S\@!
            > Thanks Tim, this works perfectly when tested with matchstr(),
            > however I need ti in a syntax file and there it appears to be a
            > noop. I tried;
            > syn match last_url '\(http\S*\/\)\@<=\w\+\/\=\S\@!'
            >
            > Any ideas?
            >
            It should "work perfectly" as is in a syntax file, too. I suspect that
            you have some syntax priority issues going on.

            * later syntax takes priority over earlier syntax:
            syn clear
            syn match One 'abc'
            syn match Two 'abc'

            hi link One Function
            hi link Two Identifier

            use this with a file containing only "abc". Result: abc is highlighted
            using #2 (Identifier). Swap syn-matches One and Two and abc will be
            highlighted using #1.

            * regions have their own syntax highlighting, and may contain other
            syntax recognition.
            * nextgroup elevates priority of such syntax

            Anyway, its involved. So, may I suggest trying my plugin

            http://www.drchip.org/astronaut/vim/index.html#HILINKS

            with its :HLT! command, move the cursor over the url: you'll be told
            what highlighting groups are in use with the text under the cursor.

            Regards,
            Chip Campbell

            --
            --
            You received this message from the "vim_use" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php

            ---
            You received this message because you are subscribed to the Google Groups "vim_use" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
            For more options, visit https://groups.google.com/d/optout.
          Your message has been successfully submitted and would be delivered to recipients shortly.