I need to compare strings such that certain conditions are met. The conditions are not necessarily patterns that I can match using a regex but rather "expression" conditions.
For instance I would like to match a string when a number is between 2 values:
inputString = "The price of a flight to Paris is 550$ and tomorrow will go up by 150$"
matchingCondition = "The price of a flight to Paris is EXPRESSION( 500 < X < 600)$ and tomorrow will go up by EXPRESSION(100 < Y < 200)$"
I need to run this comparison on random texts that don't necessarily look anything like the input string in question.
i.e.
inputString = "blah blah blah"
I would like to be able to compare using a simple true/false function. i.e.:
match(inputString,matchingCondition) -> Boolean
examples:
match(inputString : "The price of the flight is 400$",matchingCondition : "The price of the flight is EXPRESSION( 300$ < X < 401)$") -> true
match(inputString : "The price of the flight is 402$",matchingCondition : "The price of the flight is EXPRESSION( 300$ < X < 401)$") -> false
match(inputString : "Blah blah blah",matchingCondition : "The price of the flight is EXPRESSION( 300$ < X < 401)$") -> false
Is there a way to accomplish this type of comparison (using NSPredicate
for example)