4
Answers

find same words in string expression

Ajay Mavatkar

Ajay Mavatkar

7y
256
1
I have a expression like as follows,
 
(Age = 20 and Age = 30 and Age = 40)
 
I want to convert the above expression as
 
Age IN (20,30,40)
 
Can any help? 
Answers (4)
1
Amit Gupta

Amit Gupta

NA 16.5k 25.7k 7y
Use Replace function to generate your desired output
 
  1. string age ="(Age = 20 and Age = 30 and Age = 40)";  
  2. var value = "Age in" + age.Replace("Age","").Replace("=","").Trim().Replace("and",",").Trim();  
 
 Isnt simple?
Accepted
0
Vivek Kumar

Vivek Kumar

NA 7.6k 729.8k 7y
Are you using c#? Can you wite your sample code? 
0
Ajay Mavatkar

Ajay Mavatkar

NA 55 4k 7y
Actually the string expression (Age = 20 and Age = 30 and Age = 40) needs to be converted to 
Age IN (20,30,40) to execute query. The above expression is stored in a string variable 
0
Vivek Kumar

Vivek Kumar

NA 7.6k 729.8k 7y
 what do you want ? Can you elaborate your question?