Solved

regex to extract ip:john

Posted on 2016-10-21
17
77 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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Python - desktop use 1 50
storing csv file in table variable in Python 2 64
batch file or script 4 50
Regex - Capture everything between two strings. 8 28
Strings in Python are the set of characters that, once defined, cannot be changed by any other method like replace. Even if we use the replace method it still does not modify the original string that we use, but just copies the string and then modif…
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 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 how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

733 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