0

I got a massive document with text. I want to mark all the URLs ending with .se

I managed to mark the part of the url just before .se with \w+\.se. But some of these URLs got 3-4 subdomains.

So if I have example.example.example.se I manged to mark the last example.se but I want to mark it all.

Edit: To be clear, I need to mark all of the URLs to censure them. Using \w+.se will mark the "example.se" in "example.example.se" \w+.\w+.se will not mark URLs that are just "example.se" but it will mark "example.example.se

First I thought I could just do this once for every set of subdomains. But the problem is the first example in the edit. It will replace the later part of the domain but the first subdomains will remain and I wont be able to run the seq. in the chain. Cause that will then be "example.censured" (that used to be "example.example.se".

Am I making any sense? Not sure how to put the problem in words ...

1 Answer 1

1

Simply allow the part \w+\. to repeat: (\w+\.)+se.

3
  • Problem with this it still only takes on the ones with that amount of subdomains, I got some with 3 and some with 4, some with just 1.
    – Zuusu
    Mar 11, 2014 at 12:00
  • @Zuusu: That would happen with an expression like \w+\.\w+\.\w+\.se. The second plus symbol in (\w+\.)+se matches the part in parentheses as often as possible and at least once, so the expression will match both 'example.se' and 'oh.so.many.subs.example.se'. Mar 11, 2014 at 16:22
  • Ahh I see, sorry, been writing a report all day was a bit slow! Thanks alot!
    – Zuusu
    Mar 11, 2014 at 17:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .