Solved

regex to extract ip:john

Posted on 2016-10-21
17
58 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 48

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 83

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
 
LVL 48

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 48

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 48

Expert Comment

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

Open in new window

1
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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 48

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 48

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 48

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Variable is a place holder or reserved memory locations to store any value. Which means whenever we create a variable, indirectly we are reserving some space in the memory. The interpreter assigns or allocates some space in the memory based on the d…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

746 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now