Reputation: 109
Input:
.city.playground[?(@.playhouse == 'true' && @.IsPoolAvailable=='true')].checked]
Output:
.city.poolavailable.checked
Regex to convert input to output:
result = result.replace("playground[?(@.playhouse == 'true' && @.IsPoolAvailable=='true')]",'poolavailable');
This regex does not render the expected output. Please help with any other regex that can be used.
Upvotes: 1
Views: 149
Reputation: 99
you can use the capture group to solve it.As follow:
result.replace(/(\.city\.).*?(\.checked)\]/i,'$1poolavailable$2');
Upvotes: 0
Reputation: 9619
You need to escape the special characters in your regex. Use:
playground\[\?\(@\.playhouse\s*==\s*'true'\s+&&\s+@\.IsPoolAvailable\s*==\s*'true'\)\](\.\S+)\]
Then replace the match with poolavailable$1
.
result = result.replace("playground\[\?\(@\.playhouse\s*==\s*'true'\s+&&\s+@\.IsPoolAvailable\s*==\s*'true'\)\](\.\S+)\]", "poolavailable$1");
Upvotes: 1
Reputation: 735
You can try this regular expression:playground\[\?\( @\.IsPoolAvailable=='true'\)\]
Upvotes: 0