Solved

regex to extract ip:john

Posted on 2016-10-21
17
97 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 7
17 Comments
 
LVL 52

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 85

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 52

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 52

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 52

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 52

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 52

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 52

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
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…

630 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