For example:
(regexp-match #rx"a|b" "cat")
I would like to bind a variable to "a|b" so that I can create the pattern dynamically.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can build the pattern dynamically according to your needs (see the documentation), like this:
Notice that a pattern is just a string, the
regexpprocedure takes care of turning it into a regular expression object. The#rx""notation is just a literal representation of a regex, you can achieve the same effect by using theregexpprocedure. After that, the regular expression can be bound to a variable:Or used as a procedure parameter:
Or any other way you fancy.