Solved

regex to extract ip:john

Posted on 2016-10-21
17
73 Views
Last Modified: 2016-10-21
for windows os,batch ,python script to extract this:
I use Word List Updater 2.7 for regex:

my list:

120.120.1.1:john
:jim
200.255.10.17:miriam

Open in new window


Final Output.txt :

120.120.1.1:john
200.255.10.17:miriam
0
Comment
Question by:john lambert
  • 9
  • 7
17 Comments
 
LVL 50

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 41853572
Hi,
pls try
^(?:[0-9]{1,3}\.){3}[0-9]{1,3}:\w*

Open in new window

or
^[\d.]+:\w*

Open in new window

Regards
1
 
LVL 84

Expert Comment

by:oBdA
ID: 41853583
Batch:
findstr.exe /r "^[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*:..*" Input.txt >Output.txt

Open in new window

Powershell:
Get-Content .\Input.txt | Where-Object {$_ -match '\A(\d{1,3}\.){3}\d{1,3}:.+'} | Set-Content .\Output.txt

Open in new window

0
 

Author Closing Comment

by:john lambert
ID: 41853588
thank you, works perfect!!!
0
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
LVL 50

Expert Comment

by:Rgonzo1971
ID: 41853607
then try
(?:[0-9]{1,3}\.){3}[0-9]{1,3}:\w*

Open in new window

1
 

Author Comment

by:john lambert
ID: 41853618
sitll have a problem with this 1'st list how to extract this:

1'st list:
Jasondemo33@fidnet.com:216.145.157.22:mountainman01
:nouha:nouha.chamiaa@hotmail.com:105.155.104.115:nouhaila1
:rohan:rohan4674@gmail.com:59.145.117.74:123456Aa

i want output this:

216.145.157.22:mountainman01
105.155.104.115:nouhaila1
59.145.117.74:123456Aa


regex code plz?
thank you an have a wonderfull day
0
 
LVL 50

Expert Comment

by:Rgonzo1971
ID: 41853626
Have you tried last one?
0
 

Author Comment

by:john lambert
ID: 41853629
yes but dones't work...NO EFFECT,after i use this regex :
(?:[0-9]{1,3}\.){3}[0-9]{1,3}:\w*
list no changes,keep the same order
0
 
LVL 50

Expert Comment

by:Rgonzo1971
ID: 41853636
and this one
[0-9.]{7,15}:\w*

Open in new window

1
 

Author Comment

by:john lambert
ID: 41853645
ok so both regex codes do the same thing,this is the list i try to filter:
gjavado@live.nl:87.195.162.98:123test
luis-diego13@hotmail.com:186.32.163.143:copito0
bluekesler:bkesler.bavc@gmail.com:75.18.169.109:n1nja5kill
Jasondemo33@fidnet.com:216.145.157.22:mountainman01

Open in new window


I Open the tool and then i paste ur code then i choose: ''Remove pattern from word''and i got this result,check snapshot bellow:
EasyCapture12.jpg
0
 
LVL 50

Expert Comment

by:Rgonzo1971
ID: 41853650
retain I would think not remove
0
 

Author Comment

by:john lambert
ID: 41853667
if i use RETAIN then the output is completely Empty
0
 

Author Comment

by:john lambert
ID: 41853672
we can sue remove pattern and remove only that part...or..i don't know...
0
 
LVL 50

Expert Comment

by:Rgonzo1971
ID: 41853685
and delete word if not found?
0
 

Author Comment

by:john lambert
ID: 41853725
No changes:

[code]yeyeroma-6@yahoo.co.id:yeyeroma-6@yahoo.co.id:180.251.219.94:mayor1234
.:unkers200@rambler.ru:85.174.1.150:n1e2a99
:a.alqatamin90@yahoo.com:149.200.178.13:A.alqatamin90@yahoo.com
:aliaabd20@yahoo.com:37.239.248.12:zhraa123
:alirezataherkhani2015@gmail.com:2.182.204.40:102030a
:alyas.man@hotmail.com:188.161.66.146:saed123456789
:amin.bazzi0111@gmail.com:2.181.166.36:2JB9pWTY4MwJENnU
:amindarvish25.b13@gmail.com:87.236.210.217:1598741236987a

Open in new window

[/code]
0
 
LVL 50

Expert Comment

by:Rgonzo1971
ID: 41853731
sorry can't help further
0
 

Author Comment

by:john lambert
ID: 41853734
if u want i can uplaod the tool and u can test in ur pc, would be easier
0
 

Author Comment

by:john lambert
ID: 41853738
anyway ur good with regex codes etc..congratulation!!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Flask is a microframework for Python based on Werkzeug and Jinja 2. This requires you to have a good understanding of Python 2.7. Lets install Flask! To install Flask you can use a python repository for libraries tool called pip. Download this f…
You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question