0

Hi I am getting Text responses and I want to match them using Regex and apply the necessary function For instance suppose if I get a text "34n5n5: What is the result of 5 plus 0" I pass it to a function to get required output

How do I use the matchRegex function in haskell to match this Text. If there is a better way to match then please tell that also.

For example for this request

"34n5n5: What is the result of 5 plus 0"

Here "34n5n5" can be different for different requests

The numbers (5 0) can change

2
  • If you would show us some Haskell (even if completely wrong) this would give us a better idea of what exactly you are asking, and what exactly you don't understand about matchRegex. It might even make you find the answer yourself! Commented Feb 14, 2015 at 8:41
  • Actually I have figured it out. I am using Test.Regix.Posix. This will return true if the input string matches (x =~ " what is [0-9]* plus [0-9]*" ::Bool) Commented Feb 14, 2015 at 9:21

1 Answer 1

2

I figured it out. Posting it here for the benefit of others

I am using Text.Regix.Posix. This will return True if the input string matches:

x = "34n5n5: What is 5 plus 0"
result = (x =~ " what is [0-9]* plus [0-9]*" ::Bool)

will bind result to True

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.