Solved

Regex to filter only IP's?

Posted on 2016-11-20
4
64 Views
Last Modified: 2016-11-20
How to filter this IP only?

89.35.24.74     7 msmta9.newcombo.net  
89.35.24.83     8 msmta18.newcombo.net
12.35.24.83     8 msjohn123
100.200.30.20  rapasins

Output:

89.35.24.7
89.35.24.83
12.35.24.83
100.200.30.20
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
4 Comments
 
LVL 50

Expert Comment

by:Rgonzo1971
ID: 41895051
Hi,

pls try
\b([0-9]{1,3}\.){3}[0-9]{1,3}\b

Open in new window

Regards
0
 
LVL 27

Expert Comment

by:skullnobrains
ID: 41895058
you don't need an ereg if you just want the first column

in shell scripting you can do this

while read ip junk ; do echo $ip ; done <INPUT_FILE >OUTPUT_FILE

what is tyour environment ? unix shell ? windows shell ? perl ? asp ?
0
 
LVL 35

Accepted Solution

by:
Dan Craciun earned 500 total points
ID: 41895088
awk "BEGIN { FS=""" """ } { print $1 }" sterge.txt

Open in new window


Result:
89.35.24.74
89.35.24.83
12.35.24.83
100.200.30.20

Open in new window


HTH,
Dan
0
 

Author Closing Comment

by:john lambert
ID: 41895090
thank you!!!ur the best!!
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

Suggested Solutions

Title # Comments Views Activity
Regular Expression Question 9 79
URL's dynamic 4 36
Powershell String Parsing with Regular Expression 19 76
Grep - regex - find files matching pattern 2 75
As most anyone who uses or has come across them can attest to, regular expressions (regex) are a complicated bit of magic. Packed so succinctly within their cryptic syntax lies a great deal of power. It's not the "take over the world" kind of power,…
Do you hate spam? I do, and I am willing to bet you do as well. I often wonder, though, "if people hate spam so much, why do they still post their email addresses on the web?" I'm not talking about a plain-text posting here. I am referring to the fa…
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…
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…

749 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