Solved

regex to extract ip:john

Posted on 2016-10-21
17
69 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 49

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 49

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 49

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 49

Expert Comment

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

Open in new window

1
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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 49

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 49

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 49

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Task showing running status in Task Scheduler 5 60
Vbscript 8 81
Modify a small python script 19 97
Regex in JavaScript to validate US phone number with hyphens 3 28
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 lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
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…

896 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

13 Experts available now in Live!

Get 1:1 Help Now