Powershell regex help

5 comments

Gon

Well-Known Member
429
127
43
2014
295
thanks for the reply. i have the notepad++ regex code which i posted in my first post. what i am looking for instead of using notepad++, i want to use powershell for the replace.
 

Tango

Super Moderator
3,544
916
113
2009
1,250
Powershell would be very similar.

Code:
 "https://rapidgator.net/file/asdcb6af26/test.rar" -replace "https://rapidgator.net/file/(.*)\/(.*)", '$2'
 
  • Like
Reactions: Gon

Tango

Super Moderator
3,544
916
113
2009
1,250
If you want to grab filenames from all lines in file & save to a new file, this will do it, this presumes the existing file is empty.


Code:
foreach($line in [System.IO.File]::ReadLines("e:\rg.txt")) {$line.split('/')[-1] | Add-Content e:\test.txt}
 
  • Like
Reactions: Gon

Gon

Well-Known Member
429
127
43
2014
295
i solved the issue different way after seeing your code, thanks :D
 
Last edited:
Top Bottom