2

I am trying to extract the list of URLs from the text file using notepad++ and have tried different expressions as well, but it is replacing the URLs instead of extracting them.

href="https://prnt.sc/2oz4yt" class="external-link" rel="nofollow noreferrer">https://prnt.sc/4om4fj</a></p>
    <br/>
    <br/>

I have large text file like mixture content inside it but I want to extract only prnt.sc list from it

https://prnt.sc/2oz4yt
https://prnt.sc/4om4fj

how to achieve this?

2
  • Interesting... the ampersands are valid parts of URLs but are obviously junk in this case. You might need to run a Find/Replace on those first before trying any regex.
    – Burgi
    Commented Jan 30, 2020 at 10:33
  • yes, whatever the best solution, waiting for the answer! i have more than 250 prnt.sc URLs in 1 file contain same mixture of tags from where i want to extract the specific domain URL with specific length!
    – Mr.Devops
    Commented Jan 30, 2020 at 10:37

1 Answer 1

3
  • Ctrl+H
  • Find what: \G(?:(?!https://prnt.sc/\w{6}).)*(https://prnt.sc/\w{6})?
  • Replace with: (?1$1\n)
  • CHECK Match case
  • CHECK Wrap around
  • CHECK Regular expression
  • CHECK . matches newline
  • Replace all

Explanation:

\G                      # restart from last match position
(?:                     # non capture group
  (?!                   # negative lookahead, make we haven't after:
    https://prnt.sc/      # literally
    \w{6}                 # 6 word characters
  )                     # end lokkahead
  .                     # any character
)*                      # end group may appear 0 or more times
(                       # group 1
    https://prnt.sc/      # literally
    \w{6}                 # 6 word characters
)?                      # end group, optional

Replacement:

(?1         # if group 1 exists
  $1        # keep it
  \n        # line break, you could use \r\n for windows end of line
)           # end condition

Screen capture (before):

enter image description here

Screen capture (after):

enter image description here

2
  • 1
    Awesome! just solved my problem by using your suggestion and 1 change is by deselecting .matches newline.
    – Mr.Devops
    Commented Jan 30, 2020 at 11:29
  • 1
    @Raza: You're welcome, glad it helps.
    – Toto
    Commented Jan 30, 2020 at 11:32

You must log in to answer this question.

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