shortening url
-
hello
i need to shorten urls form form
http://members.home.nl/mtettero/Anecdotes.html http://members.home.nl/p.wakkermans/fr_rotterdam.htm
to
http://members.home.nl/mtettero/ http://members.home.nl/p.wakkermans/
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 usingCtrl+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.+
REPLACE
Leave EMPTY
-
Select the
Regular expression
search mode -
Click, exclusively, on the
Replace All
button
Best regards,
guy038
-
-
it still keeps some of them
http://members.home.nl/kees.de.boer/parenteel/ http://members.home.nl/kees.de.boer/parenteel/ http://members.home.nl/gvandorst/uitslag3/ http://members.home.nl/hedi/websites/voetbal/2009_2010/BB_7/
-
@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
-
my raw data looks like
http://members.home.nl/aadedelbroek/,http://members.home.nl/aadedelbroek/ http://members.home.nl/haven.21/,http://members.home.nl/haven.21/ http://members.home.nl/mtettero/Anecdotes.html,http://members.home.nl/mtettero/Anecdotes.html http://members.home.nl/p.wakkermans/fr_rotterdam.htm,http://members.home.nl/p.wakkermans/fr_rotterdam.htm http://members.home.nl/mtettero/Genealogie.html,http://members.home.nl/mtettero/Genealogie.html http://members.home.nl/aadedelbroek/parenteel_edelbroek_werkhoven/parenteel%20edelbroek-000003-p-br.htm,http://members.home.nl/aadedelbroek/parenteel_edelbroek_werkhoven/parenteel%20edelbroek-000003-p-br.htm http://members.home.nl/peter-simonis/nieuwsbrief9.htm,http://members.home.nl/peter-simonis/nieuwsbrief9.htm http://members.home.nl/m.tettero/,http://members.home.nl/m.tettero/ http://members.home.nl/pcmvandijk/biography%20tegels.html,http://members.home.nl/pcmvandijk/biography%20tegels.html http://members.home.nl/eddy.megens/Mijn%20webs/,http://members.home.nl/eddy.megens/Mijn%20webs/ http://members.home.nl/peter-simonis/nieuwsbrief1.htm,http://members.home.nl/peter-simonis/nieuwsbrief1.htm http://members.home.nl/gvandorst/uitslag/stand1A.html,http://members.home.nl/gvandorst/uitslag/stand1A.html http://members.home.nl/gvandorst/uitslag3/31A.html,http://members.home.nl/gvandorst/uitslag3/31A.html http://members.home.nl/c.peppelenbos/mitche.htm,http://members.home.nl/c.peppelenbos/mitche.htm http://members.home.nl/eltjo.huizenga/guestbook1.html,http://members.home.nl/eltjo.huizenga/guestbook1.html http://members.home.nl/martwies/Niedersachsen.htm,http://members.home.nl/martwies/Niedersachsen.htm http://members.home.nl/gvandorst/uitslag/11A.html,http://members.home.nl/gvandorst/uitslag/11A.html http://members.home.nl/c.peppelenbos/landis.htm,http://members.home.nl/c.peppelenbos/landis.htm http://members.home.nl/c.peppelenbos/beller.htm,http://members.home.nl/c.peppelenbos/beller.htm http://members.home.nl/gvandorst/uitslag/slem.htm,http://members.home.nl/gvandorst/uitslag/slem.htm http://members.home.nl/w.peulen/,http://members.home.nl/w.peulen/ http://members.home.nl/heitoomar/vrijbridgeOOo.html,http://members.home.nl/heitoomar/vrijbridgeOOo.html http://members.home.nl/janenien/spares.htm,http://members.home.nl/janenien/spares.htm http://members.home.nl/haven.21/Altijd%20hard%20gewerkt.pdf,http://members.home.nl/haven.21/Altijd%20hard%20gewerkt.pdf http://members.home.nl/mtettero/Genealogie%EBn.html,http://members.home.nl/mtettero/Genealogie%EBn.html http://members.home.nl/d.bruls/reisverslag2.html,http://members.home.nl/d.bruls/reisverslag2.html http://members.home.nl/cda-boz/SMR.html,http://members.home.nl/cda-boz/SMR.html
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,
guy038
-