2023-01-24 01:58 PM
Hello community. I have question. I would like to use regular expressions regex. It adds #include <regex.h> and tries to use the regcomp or regexec function. Unfortunately after compilation I get the error "undefined reference to regcomp". How do I get regex to work in CubeIDE version 1.11.0, what do I need to do?
2023-01-24 09:46 PM
regex.h is not part of the C language standard. See this thread: https://community.st.com/s/question/0D53W00000zH6vWSAS/in-mainc-i-have-include-regexh-and-calls-to-regcomp-and-regexec-in-the-build-output-i-receive-undefined-reference-to-regcomp-is-it-an-error-in-the-linker-stage-what-linker-setting-i-should-change
hth
KnarfB
2023-01-25 02:52 AM
I saw this topic but I don't know how i put this library https://github.com/kokke/tiny-regex-c to CubeIDE
2023-01-25 03:12 AM
git clone/download the re.c and re.h files and put them in the Inc/Src folder of your project. Include "re.h" The API is different, but looks straightforward to me.
hth
KnarfB
2023-01-25 04:09 AM
Ok I will try
2023-01-25 10:39 AM
Ok this library work but regex created by me not working in this library :( I must check string like |2|20| . I use ^\\|([0-9]+\\|)+$ .For there to be a positive result there must be two | characters and a decimal number between them. In normal c compiler this work but in this library not working
2023-01-26 09:09 AM
Have you tried testing it on https://regex101.com/ ? For me the sequence ^\|(\d+\|)+$ works on regex101. In C that would be "^\\|(\\d+\\|)+$" . If you debug the library what happens?
2023-01-26 09:15 AM
The bar | is not used in re.c so there is no need for escape. It's probably only a matter of correct backslashing. But I think the OP shall find that out by reviewing the source or debugging or trial-and-error.
hth
KnarfB