1

All the documentation I can find says this should be returning the index of the first of the three x's but instead it returns nil:

(string-match "x\{3\}" "string with 3 x's repeating: xxx")

enter image description here

update: I had to escape the backslashes:

(string-match "x\\{3\\}" "string with 3 x's repeating: xxx")
2
  • Need another backslash to escape.
    – Dan
    Commented Mar 18, 2016 at 1:38
  • 2
    Please write up the answer as an answer, and accept it. (It's fine to accept your own answer.)
    – Drew
    Commented Mar 18, 2016 at 4:43

1 Answer 1

0

Backslashes need to be escaped in strings:

(string-match "x\\{3\\}" "string with 3 x's repeating: xxx")

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.