shortening url

  • hello

    i need to shorten urls form form


    is there a way to do that in notepad

  • @Wessel-Bogers said in shortening url:

    is there a way to do that in notepad

    Yes. How would you do it if you were explaining the algorithm to someone? “Look for the last /, and delete everything after that”. So then create a regex that implements that.

    For example, finding /\K[^/\r\n]*$ will look for a slash, then reset the match (so the slash won’t get deleted), then look for 0 or more characters that are neither slash or newlines until the end of the line. Replace that with the empty string. (And of course, regular expression must be enabled). If that pattern is matched, then the final filename will be deleted; if that pattern doesn’t match, nothing will be deleted, of course.

    Do you want regex search/replace help? Then please be patient and polite, show some effort, and be willing to learn; answer questions and requests for clarification that are made of you. All data / example text should be marked up as plaintext using the </> toolbar button or manual Markdown syntax; screenshots can be pasted in natively using Ctrl+V when you have the image in your clipboard. Show the data you have; show the regex you tried, and why you thought it should work; show what you get, and compare it to what you wanted to get; make sure to include examples of things that should match and be transformed, and things that don’t match and should be left alone. Read the official NPP Searching / Regex docs and the forum’s Regular Expression FAQ.
    We sometimes vent our frustration when all a particular user does is demand the answer be given to them after many changes of requirements, or comes back time and again for new “gimme” requests, without showing any effort. But if you follow these guidelines, you’re much more likely to get helpful replies that solve your problem in the shortest number of tries.

  • Hello, @wessel-bogers, @peterjones and All,

    Hi, Peter, just an other syntax :

    SEARCH (?-s).+/\K.+


    • Select the Regular expression search mode

    • Click, exclusively, on the Replace All button

    Best regards,


  • @guy038

    it still keeps some of them

  • @Wessel-Bogers ,

    @guy038 's worked perfectly for all the example data you originally showed. We both made assumptions about what larger set your data represented (consciously or not), and gave the best regex we could that fits the data we could see with those assumptions.

    If you want better help, you have to give better example data.

    And I need to tweak my boilerplate again (which I’m trying to condense and make more likely for people to read), because in this shortened version, I forgot to mention that edge cases should be included in example data as well. sigh

  • @PeterJones

    my raw data looks like,,,,,,,,,,,,,,,,,,,,,,,,,,,

    a small sample

  • Every post, you’ve made it more confusing. You didn’t used to have commas, and now I don’t know what you want to replace and what you don’t.

    If you want more help than what Guy and I have already given, you are going to have to make your desires more clear.

    Show the data you have and the text you want to get from that data; include examples of things that should match and be transformed, and things that don’t match and should be left alone; show edge cases and make sure you examples are as varied as your real data. Show the regex you already tried, and why you thought it should work; tell us what’s wrong with what you do get.

  • Hi, @wessel-bogers, @peterjones and All,

    @wessel-bogers, and All, when, you ask for modifications of data, with regular expresions, please, please …

    • Give us a fairly large amount of your  INPUT  text ( as you did,@wessel-bogers, in your previous post )

    • Give us, also, the expected  OUTPUT  text, from your specific  INPUT  test. That’s the  KEY  point !

    Then, from the differences between these two texts, even if you cannot express simply yourself, regarding your goal, we should be able to guess your needs, most of the time ;-))

    Remember : If you clearly defined the rules to process, in your  INPUT  text, half the job is already done ;-))

    See you later,

    Best Regards,


Log in to reply