Hi,

<DIV style="POSITION: absolute; TEXT-ALIGN: center; FONT-STYLE: normal; WIDTH: 141px; FONT-FAMILY: Arial; WHITE-SPACE: nowrap; HEIGHT: 76px; FONT-SIZE: 12pt; TOP: 268px; FONT-WEIGHT: 400; TEXT-DECORATION: none; ctrlProp="acknowledged:true;showDisableIcon:True;showTooltip:True;sizeableIcon:True;"></DIV>

Consider the above string, Now I want to know the value of sizeableIcon (Either true/false),showDisableIcon (either true /false). Is there any way to pick those values.

Note: I don't want to use split(";") method. It should be professional way.

try something like:

        dim substart,subend as Integer
        dim originalstring,newstring,searchstring as string

            'Set search term
            searchstring = "showDisableIcon"

            'find the start of the string you want to extract
            substart= originalstring.indexof(searchstring)

            'find the end of the string you want to extract
            subend= originalstring.indexof(';', substart)

            'newstring should contain the string your looking for.  
            newstring = originalstring.substring(substart,subend)

            'Check for boolean value.
            if newstring.contains("True") then
                'do stuff
            else
                'do other stuff
            endif

This was done without an IDE, syntax may not be 100%.

Edited 3 Years Ago by tinstaafl

@tinstaafi: did you not notice, this is the C# forum not the VB.NET forum?
Don't worry, I made the same mistake once, and I still live! :)

Something like

String str = //your string here 
MatchCollection matches = Regex.Matches(str, "(?<=sizeableIcon:)(.*?)(?=;)");
foreach (Match match in matches) {
   //do something with each match
}

oops, an attack of braindeadedness lol. Here this one should be better.

    int substart=0,subend=0;
    string originalstring,newstring,searchstring;

    //Set your original string
    originalstring="<DIV style="POSITION: absolute; TEXT-ALIGN: center; FONT-STYLE: normal; WIDTH: 141px; FONT-FAMILY: Arial; WHITE-SPACE: nowrap; HEIGHT: 76px; FONT-SIZE: 12pt; TOP: 268px; FONT-WEIGHT: 400; TEXT-DECORATION: none; ctrlProp="acknowledged:true;showDisableIcon:True;showTooltip:True;sizeableIcon:True;"></DIV>"

    //Set search term
    searchstring = "showDisableIcon";

    //find the start of the string you want to extract
    substart= originalstring.indexof(searchstring);

    //find the end of the string you want to extract
    subend= originalstring.indexof(';', substart);

    //newstring should contain the string your looking for.
    newstring = originalstring.substring(substart,subend);

    //Check for boolean value.
    if (newstring.contains("True"))
    {
    'do stuff
    }
    else
    {
    'do other stuff
    }

Edited 3 Years Ago by tinstaafl

This article has been dead for over six months. Start a new discussion instead.