0

i've this url

https://www.mirrored.to/files/12345678/abcdefgh

and I need to change this replace the / with space before the a alphabet 2 Space

https://www.mirrored.to/files/12345678 abcdefgh

3
  • regex101.com and Notepad++'s search and replace function.
    – Gantendo
    Commented Sep 10, 2023 at 6:50
  • I found two spaces. Do you want to replace the last / by one space or two spaces? Edit your question and improve formatting for better reading. e.g. four blanks at beginning of text (code) lines. Commented Sep 10, 2023 at 6:53
  • 1
    @help-info.de Teach a man to fish...
    – Gantendo
    Commented Sep 10, 2023 at 7:26

2 Answers 2

2
  • Ctrl+H
  • Find what: /(?!.*/)
  • Replace with: # 2 spaces
  • TICK Wrap around
  • SELECT Regular expression
  • Replace all

Explanation:

/           # a slash
(?!.*/)     # negative lookahead, make sure we haven't another slash after

Screenshot (before):

enter image description here

Screenshot (after):

enter image description here

1
  • THANK YOU THIS WORKS Commented Sep 10, 2023 at 10:40
2

Lets say you have your single URL or some more in a text file line by line

https://www.mirrored.to/files/12345678/abcdefgh
https://superuser.com/questions/1807813/insert-a-space-in-line-after-notepad
https://stackoverflow.com/questions/76245266/adding-characters-to-the-first
https://www.mirrored.to/files/12345678/ABCDEFGH

you'd go through following steps:

  • Ctrl+H
  • Find what: ^(.+\d)(\/)(.+$)
  • Replace with: $1 $3
  • Tick the Wrap around option
  • Search mode: Regular expression
  • Click on Replace All (at your own risk)

Explanation:

^ asserts position at start of a line
1st Capturing Group (.+\d)
    .     # matches any character (except for line terminators)
    +     # matches the previous token between one and unlimited times
    \d    # matches a digit (equivalent to [0-9])
2nd Capturing Group (\/)
    \/    # matches the character /

3rd Capturing Group (.+$)
    .     # matches any character (except for line terminators)
    +     # matches the previous token between one and unlimited times
    $     # asserts position at the end of a line

Screenshot (before):

enter image description here

Screenshot (after):

enter image description here

You must log in to answer this question.

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