RegEx solution to evaluate URL string - keep only the ending
-
I have several lines in NPP like so:
https://www.website.com/blah/157845121/Keep_This_Portion/
I’m wondering if there is a RegEx solution that can delete everything and keep just the very last part where it says
Keep_This_Portion
I actually need the underscore removed as well. The sequence of numbers that appear before it, will always vary.
—
moderator added code markdown around text; please don’t forget to use the
</>
button to mark example text as “code” so that characters don’t get changed by the forum -
In response to your July regex query, I pointed these references to you:Useful References
- Please Read Before Posting
- Template for Search/Replace Questions
- Formatting Forum Posts
- Notepad++ Online User Manual: Searching/Regex
- FAQ: Where to find other regular expressions (regex) documentation
You apparently didn’t avail yourself of that knowledge in the last 4 months, to learn how to properly format the question so that example text doesn’t get linkafied, thus forcing me to use moderator powers to fix your post.In April, I had previously pointed those out to you in regard to your regex question.At this point, I’m going to share something more specific to your circumstances:—
Please note: This Community Forum is not a data transformation service; you should not expect to be able to always say “I have data like X and want it to look like Y” and have us do all the work for you. If you are new to the Forum, and new to regular expressions, we will often give help on the first one or two data-transformation questions, especially if they are well-asked and you show a willingness to learn; and we will point you to the documentation where you can learn how to do the data transformations for yourself in the future. But if you repeatedly ask us to do your work for you, you will find that the patience of usually-helpful Community members wears thin. The best way to learn regular expressions is by experimenting with them yourself, and getting a feel for how they work; having us spoon-feed you the answers without you putting in the effort doesn’t help you in the long term and is uninteresting and annoying for us.
—
note on edits: I had edited my post within 10 minutes of posting it, trying to tone things down, and my edits were done 10 minutes before any replies were posted. But it apparently wasn’t enough, and now I’ve been accused of trying to “change history” or some such, so I have restored my original phrasing, but in
strikeout mode, so everyone can see how rude they think I was originally, and how I tried to soften my phrasing to be kinder (apparently unsuccessfully). After restoring thesestrikeoutsections, I will be leaving this discussion, because it’s not helping anybody. -
@JustinJudo said in RegEx solution to evaluate URL string:
I’m wondering if there is a RegEx solution that can delete everything and keep just the very last part where it says
Quite easily done, especially if someone were to have started learning regex back in April when one was pointed to the documentation,
rather than hoping that people would spoonfeed them the answers. You will never learn if you don’t try.But since you seem to need it:
FIND =^https://www.website.com/blah/\d+/(.*)/
REPLACE =$1
I actually need the underscore removed as well.
Well, then you really shouldn’t’ve included the underscores in the “what I want” section.
I’d do that as a separate search-and-replace, where you look for the underscore and replace it with a space. I am going to assume you can figure out a regex to replace an underscore with a space.Good luck.
—
note on edits: I had edited my post within 10 minutes of posting it, trying to tone things down, and my edits were done 10 minutes before any replies were posted. But it apparently wasn’t enough, and now I’ve been accused of trying to “change history” or some such, so I have restored my original phrasing, but in
strikeout mode, so everyone can see how rude they think I was originally, and how I tried to soften my phrasing to be kinder (apparently unsuccessfully). After restoring thesestrikeoutsections, I will be leaving this discussion, because it’s not helping anybody. -
@PeterJones said in RegEx solution to evaluate URL string:
Quite easily done, especially if someone were to have started learning regex back in April when one was pointed to the documentation. You will never learn if you don’t try.
You’re unbearable. If you can’t be afford to be civil or polite in your response, then just keep out of the thread. There’s just no need for any of your snarky attitude.
-
@JustinJudo
I knowIn case you can’t see who down voted you,butit was me. I’ll own it because otherwise you will think @PeterJones did it.I did it because frankly your attitude sucks. You were provided the solution and politely steered (again) in the direction of documentation which will help you learn.
We’re not asking you to know it all right now, but if you’d come with the above question and shown a bit of work (since this isn’t your first question), we will be very happy to help.
Perhaps take this on board, you will likely need our help again, more than we need yours. Tone your attitude down!
Terry
-
@Terry-R said in RegEx solution to evaluate URL string - keep only the ending:
I know you can’t see who down voted you
I could be wrong about this, but I think you CAN see who downvoted one of YOUR postings, but other people can’t.
-
@JustinJudo said :
You’re unbearable.
Hmmm, someone is “unbearable” because they’re speaking the bald truth – I don’t think so. You’re just mad because you got called out on being lazy and are just attempting to lean on others to do your thinking and problem solving for you.
If you can’t be afford to be civil or polite in your response, then just keep out of the thread.
The response was both civil and polite. And Peter, as a tireless moderator, has a duty to respond in the manner he did. And it is really hard to believe you responded in the way that you did, when he still gave you the answer to your need.
OK, yep, I’ll downvote too.
-
@JustinJudo said in RegEx solution to evaluate URL string - keep only the ending:
@PeterJones said in RegEx solution to evaluate URL string:
Quite easily done, especially if someone were to have started learning regex back in April when one was pointed to the documentation. You will never learn if you don’t try.
You’re unbearable. If you can’t be afford to be civil or polite in your response, then just keep out of the thread. There’s just no need for any of your snarky attitude.
Sorry, I thought I deleted that, along with some other stuff, because I realized I let my emotions get the better of me.
But even without my intended edit, while frustrated with you, I still handed you the answer, for free. But if you want to whine about how awful I am for including snark along with the right answer, you go right on ahead.
-
I’m going to keep this short (and recommend not responding because it would go off-topic and I’m not that familiar with it anyway) because it’s not a Notepad++ topic really, but strongly recommend using Python’s urllib.parse module for this purpose, which is accessible via PythonScript or just a normal non-Notepad++ Python script.
-
@Terry-R said in RegEx solution to evaluate URL string - keep only the ending:
@JustinJudo
I knowIn case you can’t see who down voted you,butit was me. I’ll own it because otherwise you will think @PeterJones did it.I did it because frankly your attitude sucks. You were provided the solution and politely steered (again) in the direction of documentation which will help you learn.
We’re not asking you to know it all right now, but if you’d come with the above question and shown a bit of work (since this isn’t your first question), we will be very happy to help.
Perhaps take this on board, you will likely need our help again, more than we need yours. Tone your attitude down!
Terry
Hey Terry, please free to downvote to your hearts content. I don’t live for fake internet points so if that is what makes you happy - go for it. Speaking of attitude by the way - you’re one to speak. If you’re really pure as the driven snow, you should have minded your own business instead of butting into a thread in which you have no business.
@Alan-Kilborn said in RegEx solution to evaluate URL string - keep only the ending:
Hmmm, someone is “unbearable” because they’re speaking the bald truth – I don’t think so. You’re just mad because you got called out on being lazy and are just attempting to lean on others to do your thinking and problem solving for you.
Holy Christ, the condescending shit here is really quite something else. The reason why I haven’t put any effort into learning RegEx is that I had a death of a family member recently so my head is in a big of a fog and I’m really not in the mood to learn any thing anything at this moment. I’m sorry if my so called “attitude” really doesn’t sit well with you guys, I have far more important things to process in my head than trying to learn RegEx today.
As for my comment about PeterJone’s attitude, he deleted his snarky and condescending snipet so it just looks like I’m criticizing him for no reason - but yeah it certainly was there… he deleted it.
Thanks all, you guys are all fantastic! Thanks for showing me your true colors today!
-
@JustinJudo said in RegEx solution to evaluate URL string - keep only the ending:
I had a death of a family member recently…I have far more important things to process in my head than trying to learn…
Yes, you do.
I’m sorry for your loss; we all go through these things. :-(Perhaps you should be taking a break from everything right now, including your original need for manipulation of URL text data – how important is that in your current state? You’re bound to make mistakes with whatever you’re trying to accomplish.
As for my comment about PeterJone’s attitude, he deleted his snarky and condescending snipet so it just looks like I’m criticizing him for no reason - but yeah it certainly was there… he deleted it
I suppose this IS a problem. If something is there long enough for someone to respond based on it, it should not be deleted or changed, lest further respondents draw potentially false conclusions. BUT… having read Peter’s posts here for years and years, I have a hugely hard time believing that anything he said was all that offensive.
A LATER EDIT: After reading Peter’s restored-but-strikethrough posting parts, assuming they are legitimate (but I’m sure they are), there’s nothing there that should have caused a flap of the magnitude that ensued. Let’s chalk it up to the OP having a bad day (or series of days/weeks when you have a death of someone close) when he wasn’t fully in his right mind.
Oh, well, let’s get back to Notepad++ business.