How to convert ...
-
I wanna to convert this string : "
if("2" == "2" && "10" >="9")
return "true";
else
return "false";if the above string contains any of these : >= , <= , > , < Replace the part of string ( "10" >= "9") TO : ( 10 >= 9) So the final string would be :
if("2" == "2" && 10 >=9 )
return "true";
else
return "false";How is it possible. note : the string may contain lot of these math operation in it .
-
I wanna to convert this string : "
if("2" == "2" && "10" >="9")
return "true";
else
return "false";if the above string contains any of these : >= , <= , > , < Replace the part of string ( "10" >= "9") TO : ( 10 >= 9) So the final string would be :
if("2" == "2" && 10 >=9 )
return "true";
else
return "false";How is it possible. note : the string may contain lot of these math operation in it .
Create a token parser. So, start at the beginning of the string and work your way over it looking for the strings you're interested in. You could do this with a regex and some fancy parsing, but I would keep it simple if I were you. There are some shortcuts that you can take, such as only needing to store the right hand side of the token if the operators are the ones you are interested in. I would also look to split my string up into an array of smaller strings using the && and || operators. Then, I would perform my search on the smaller arrays.
-
Create a token parser. So, start at the beginning of the string and work your way over it looking for the strings you're interested in. You could do this with a regex and some fancy parsing, but I would keep it simple if I were you. There are some shortcuts that you can take, such as only needing to store the right hand side of the token if the operators are the ones you are interested in. I would also look to split my string up into an array of smaller strings using the && and || operators. Then, I would perform my search on the smaller arrays.
-
Create a token parser. So, start at the beginning of the string and work your way over it looking for the strings you're interested in. You could do this with a regex and some fancy parsing, but I would keep it simple if I were you. There are some shortcuts that you can take, such as only needing to store the right hand side of the token if the operators are the ones you are interested in. I would also look to split my string up into an array of smaller strings using the && and || operators. Then, I would perform my search on the smaller arrays.
-
If the text will contain proper spacing..You may use 'Contains ()'.
string strMyText = "There is some text like 10 > 9";
if(strMyText .Contains("10 >9"))
{
strMyText = "I got it"
}Okay, two things: 1. The OP does not get notified of answers to someone other than them. 2. Your solution does not even begin to address what the OP has asked for. Take a look at his question again and ask yourself if you have really answered it.