LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Regular Expression

Hi,

I am trying to parse an IP address from a string, i am using this  :
[0-9]*.[0-9]*.[0-9]*.[0-9]*
but the * doesn't limit to 3 numbers, how can i do this parse?

0 Kudos
Message 1 of 10
(4,312 Views)
Hi Alvarion,
which function do you use to parse your string? You can also have an IP adress, where all fields have only 2 numbers. Smiley Wink

Mike
0 Kudos
Message 2 of 10
(4,307 Views)
hey,

I want to use the Match Pattern vi and i to parse any combination of the ip address, with 2,3 or even 1.
0 Kudos
Message 3 of 10
(4,305 Views)

[0-9][0-9][0-9]\.[0-9][0-9][0.9] and so on.  dont have labview up right now but this should match 3 digits folowed by a period and repete the pattern until you have the 4 triplets needed for an ip address.

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 4 of 10
(4,297 Views)
sorry didnt put much thought in my last answer, this only matched 3 numbers.  You can use the optional escape clause for the 2nd and 3rd digit [0-9].
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 5 of 10
(4,294 Views)
Thanks
0 Kudos
Message 6 of 10
(4,288 Views)
How about "String to IP" from the "communications..protocols...tcp" palette?
 
You should also be aware that each octet is U8 (0..255), so even if you limit to three digits, you could have problems, e.g. 300.400.500.600 is illegal.
0 Kudos
Message 7 of 10
(4,265 Views)
In addition to what Altenbach said, you might want to make a VI out of this with error I/O and validate the IP address in there. A very simple way of doing this is by using Scan From String with %d.%d.%d.%d as the format string and then checking the results using In Range & Coerce.

___________________
Try to take over the world!
Message 8 of 10
(4,254 Views)
Thanks to you all
0 Kudos
Message 9 of 10
(4,249 Views)

Off hand I couldnt remember but the optional escape claues in RE is ? to matching 2 or 3 numbers becomes [0-9][0-9][0-9]? and batching a period is\.  it is all comming back to me now.

 

paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 10 of 10
(4,230 Views)