Questions

comparing a string

Tags:
+
0 Votes
Locked

comparing a string

2rajesh.b
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
  • +
    0 Votes
    kam

    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.

    +
    0 Votes
    robo_dev

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

    +
    0 Votes

    :)

    cmiller5400

    Exactly what I was thinking. :)

    +
    0 Votes
    2rajesh.b

    in ASP and VB

    +
    0 Votes
    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

    +
    0 Votes
    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

    +
    0 Votes
    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.

    +
    0 Votes
    2rajesh.b

    Thanks a lot i made it

  • +
    0 Votes
    kam

    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.

    +
    0 Votes
    robo_dev

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

    +
    0 Votes

    :)

    cmiller5400

    Exactly what I was thinking. :)

    +
    0 Votes
    2rajesh.b

    in ASP and VB

    +
    0 Votes
    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

    +
    0 Votes
    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

    +
    0 Votes
    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.

    +
    0 Votes
    2rajesh.b

    Thanks a lot i made it