Skip to content
Advertisement

Fetching to substring before operator from a dynamic string

I have a string like “name = mita and salary> 10000” . Out of which I need to get only name and salary attribute.I am going to have dynamic string on which i need the attribute before operator only. Like here I need to fetch name and salary attribute which r before = and > operator. I can have multiple condition of same type in the string. I can anyone please feasible way to fetch string before operator in Java8 Please find the example strings and expected output as below:

JavaScript

Advertisement

Answer

You can make use of split method of String class and Regex :

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement