Question Locked

comparing a string

0 helpful
9 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi,
i have string str ="IP>10.2.2.1 and IP<10.2.2.10,10.2.2.31";

i have one more string str1 ="10.2.2.5";

i need to search whether str1 exists in str.

need a sample program for searching .

Thanks in Advance

9 replies

by Former member

Grep is the "best" tool to look for a string in a text file.

If you are using Linux/Unix, use grep. See http://www.gnu.org/software/grep/ for more info.

If you are using Windows, see http://gnuwin32.sourceforge.net/packages/grep.htm for more info.

Afraid of the command line (grep is a command line tool), import your text file to MS Excel, Word, etc. and use CTRL+F and search for the string that way.

by robo_dev

Check all that apply:
[ ] DOS Batch
[ ] ASP
[ ] C++
[ ] Java
[ ] Visual Basic
[ ] Fortran
[ ] ADA
[ ] SPSS-X
[ ] COBOL
[ ] Morse Code
[ ] Intel Assembler

by wancona

This is a vb script. Do you mean something like this?

On Error Resume Next

intStartingAddress = 1
intEndingAddress = 31
strSubnet = "10.2.2."
strAddress = 5

For i = intStartingAddress to intEndingAddress
strComputer = strSubnet & i
if i = strAddress AND i < intEndingAddress then
Wscript.Echo strComputer
end if
Next

by 2rajesh.b

Hi

i have a string like 'X>10.10.1.0 and x<10.10.1.10'

how can i split this into intStartingAddress = 1
intEndingAddress = 10

i need to split and check in that range whether my IP is in that range.

i am completely new to VB

by wancona

The first three octets (10.10.1.) goes into the strSubnet.

The intStartingAddress goes to 0 because that is the lesser of the two numbers in the fourth octet

The intEndingAddress goes to 10 or whatever the higher number of the last octet is.

strAddress is the number (x) in the last octet of the address you are searching for.

This small script only works on checking the last octet, but with some modifications, can work other ways.

This discussion is closed to new replies.