Relative Content

Tag Archive for regex

Conditional regex to distinguish between null and a value

I’m working on a REST api that has a GET endpoint to search for trades in the context of stock exchanges.
It supports dynamic filtering so the client can set the trade field(column), comparison operator and comparison value
he wants.
e.g. Result -eq [Win] or Result -eq [BreakEven]
The operator must start with a dash and the comparison value must be surrounded by square brackets.
Everything within the square brackets will be treated as a value.
e.g. [some-value with whitespaces, "double quotes" and [] within] are totally fine.
Between the three components of the filter there must be at least one whitespace.