473,396 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

REGEX get list of ip addresses

59
im using some regex code in vb.net to get each ip address in a list that looks like this: ip,ip,ip,ip,ip,ip,ip,ip,ip,ip etc.
but when i use this regex code
( |,).+?(,|\r\n)

it only returns every second ip address. any help is great! im new wih regex
Apr 4 '09 #1
1 3326
aryanbs
42
You could write a function like this

Expand|Select|Wrap|Line Numbers
  1.  Private Function ISValidIP(ByVal IPAddress As String) As Boolean
  2.         Dim validFormat As String = "\b(([01]?\d?\d|2[0-4]\d|25[0-5])\.){3}([01]?\d?\d|2[0-4]\d|25[0-5])\b"
  3.         Dim rxn As System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex(validFormat)
  4.         If rxn.IsMatch(IPAddress) Then
  5.             Return True
  6.         Else
  7.             Return False
  8.         End If
  9.     End Function
And Find the matching Ip from a list this way

Expand|Select|Wrap|Line Numbers
  1.  Dim AllIP As String = "192.122.123.100,122.34.233.23,190.234.33.44"
  2.         Dim IpAddesses As New List(Of String)
  3.  
  4.         For Each Str As String In AllIP.Split(","c)
  5.             If ISValidIP(Str) Then
  6.                 IpAddesses.Add(Str)
  7.             End If
  8.         Next
Apr 4 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Evangelista Sami | last post by:
Hi all i have implemented a list type as an array of pointer like this typedef struct { int nb_elements; void **elements; } list; to avoid having a pointer for each element as it is done...
17
by: clintonG | last post by:
I'm using an .aspx tool I found at but as nice as the interface is I think I need to consider using others. Some can generate C# I understand. Your preferences please... <%= Clinton Gallagher ...
13
by: Chris Lieb | last post by:
I am trying to write a regex that will parse BBcode into HTML using JavaScript. Everything was going smoothly using the string class replace() operator with regex's until I got to the list tag....
24
by: cassetti | last post by:
Here's the issue: I have roughly 20 MS excel spreadsheets, each row contains a record. These records were hand entered by people in call centers. The problem is, there can and are duplicate...
4
by: mikewolfbaltimore | last post by:
Hello all have a regex question... I want to split an address into descrete parts so 709 S Milton Ave is split into number = 709 Direction = S Name = Milton
0
by: Steve | last post by:
I've been looking for a regex expression that handles Outlook Account Names which appear to be different than Email Addresses. I'm using it for an SMTP Mail routine where I need username and...
3
by: Praveen | last post by:
looking for regex pattern for validating emailid emailid can have a-z 0-9 - _ . (a to z, 0 ot 9, hyphen,undercore, dot) here is a sample which I got from net which doesnt allow hyphen(-) ...
4
by: chris | last post by:
I need to maintain a list of subscribers to an email list for a "newsletter" that will be sent via a web form probably once a month. I anticipate low numbers--tens to maybe one hundred subscribers...
4
by: seberino | last post by:
I'm looking over the docs for the re module and can't find how to "NOT" an entire regex. For example..... How make regex that means "contains regex#1 but NOT regex#2" ? Chris
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.