LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Discover IP Address In String

Solved!
Go to solution

I am faced with an issue of finding the IP address in a string containing other string like items... such as letters and numbers and... (ok, I'm just messing around).  Anyways, the string could look like the following  "10.0.0.1 stuff, stuff, stuff" or "stuff, stuff, stuff, 10.0.0.1 stuff, stuff."  The bright side is that periods/dot is only used for IP addresses while comma is used for everything else.  So I was thinking... well ok, I could just use a while loop and match pattern to solve this one. But then I thought.... "that's so primitive.  Surely, there's a better way to do this."   Sooooooo, is there a better way to do this?  I'm using LabVIEW 2011 just an fyi.

0 Kudos
Message 1 of 9
(4,858 Views)

What's wrong with primitive?  Sounds like a good way to solve it.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 2 of 9
(4,853 Views)
Solution
Accepted by topic author DailyDose

Use "Match Regular Expression" with one of the expressions listed here: https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.ht...

 

EDIT: more specifically, you want to use one of the expressions for matching an IP address from within a larger body of text, of course.

0 Kudos
Message 3 of 9
(4,836 Views)

Hey man, we all want to move along just a little quicker (poor wheel reference)

 

Seems like the following match would be ideal to search for, 

^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$

 However, it would appear this syntax does not agree with LabVIEW.  You sure about this?

0 Kudos
Message 4 of 9
(4,826 Views)

As I noted too late in my edit, you want to use the version for finding an IP address in a larger block of text, rather than the first version on that page. the ^ and $ are beginning- and end-of-line patterns, and you're not looking for an IP address on a line by itself.

 

Other than that, is there some way in which that syntax doesn't agree with LabVIEW? Works for me once I remove the ^ and $.

Message 5 of 9
(4,820 Views)

Ok, I hate being Mr. Spoonfed, but might you be willing to post a jpg of your VI so that I may compare to mine own.  I'm using match pattern but receiving no matches.  Does your text contain more than just IP addresses?

0 Kudos
Message 6 of 9
(4,794 Views)

On second thought, here's mine

.Capture.JPG

0 Kudos
Message 7 of 9
(4,773 Views)

The function you need to use is Match Regular Expression, not Match Pattern.

Message 8 of 9
(4,763 Views)

Yep, thank you sir!

0 Kudos
Message 9 of 9
(4,736 Views)