0

I have below text:

_pranay_:pranay:104.144.219.145:3128
_ridhoo:rihdonk:104.144.224.242:3128
_shintna_10:shinhana:104.144.235.149:3128
_waled_jr_:ismail:104.144.241.222:3128

Which represent USER:PASS:PROXY

now I want to use a regular expression to remove the USER and PASS and keep the proxy.

Output like:

104.144.219.145:3128
104.144.224.242:3128
104.144.235.149:3128
104.144.241.222:3128

I've tried my best with failed attempts. am not that good in Regex. I wish somebody who can help me out. Thank you.

John fabric
  • 51
  • 1
  • 8
  • 2
    "I've tried my best with failed attempts." Show them please. That will save you from having your question closed for lack of demonstrated effort, being too broad, etc. Explain in which way they failed to satisfy you. It will also help to clarify why the most obvious solution is not working. – Yunnosch Oct 05 '19 at 20:02
  • Are you sure that it is USER:PASS:PROXY? It looks more like PASS:USER:PROXY. – Yunnosch Oct 05 '19 at 20:06

2 Answers2

0

You can use https://regexr.com/ to play around with regex. For example, the expression below captures the part you want to remove:

([_a-zA-Z]+[0-9]*:)

Or, try the expression below to match the parts you want to keep;

([\d+\.]*:[0-9]{4})

As I'm no regex-expert, there might be better expressions available. But I recommend the link I provided to learn some regex.

Rhapsody
  • 5,854
  • 2
  • 28
  • 47
0

You can maybe simply replace,

^[^:\r\n]*:[^:\r\n]*:

with an empty string.

Demo


If you wish to simplify/modify/explore the expression, it's been explained on the top right panel of regex101.com. If you'd like, you can also watch in this link, how it would match against some sample inputs.


Community
  • 1
  • 1
Emma
  • 1
  • 9
  • 28
  • 53