0

特定の条件を満たすように文字列を比較する必要があります。条件は、必ずしも正規表現を使用して照合できるパターンではなく、「式」条件です。

たとえば、数値が 2 つの値の間にある場合に文字列を一致させたいと思います。

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)$"

問題の入力文字列のように見えるとは限らないランダムなテキストに対して、この比較を実行する必要があります。

すなわち

inputString = "blah blah blah"

シンプルな true/false 関数を使用して比較できるようにしたいと考えています。すなわち:

match(inputString,matchingCondition) -> Boolean

例:

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

このタイプの比較を達成する方法はありますか (NSPredicateたとえば)

4

0 に答える 0