Boost: How to use + in C POSIX regex interface


Boost: How to use + in C POSIX regex interface



I am trying to use BOOST.Regex POSIX Compatible C API's. I am using regcomp() to match an expression like a+, which should match aa and aaa, while using cflags=REG_BASIC. I have regcomp( reg, "a+", REG_BASIC) but it is not working.


regcomp()


a+


aa


aaa


cflags=REG_BASIC


regcomp( reg, "a+", REG_BASIC)



I found a link stating that + is not part of the POSIX standard. But I found in Boost POSIX Basic regular expression documentation an Emacs variation that supports + syntax.


+


+



How can I use + in POSIX Basic Regular Expressions? Or in other words, enable Emacs variation.


+



References:





You do not need the + quantifier since you may use {1,}. + is an extension for some POSIX regex implementations (as in GNU sed), and is not portable.
– Wiktor Stribiżew
Jul 2 at 13:37


+


{1,}


+





Well, if you plan to use emacs "flavor", use boost::regex::emacs and enjoy +.
– Wiktor Stribiżew
Jul 2 at 13:50


emacs


boost::regex::emacs


+





@WiktorStribiżew Actually I am using the POSIX Compatible C API's as the APIs are called from c code. Is there a way to use boost::regex::emacs from c code?
– Mohamed Elsayed
Jul 2 at 15:22


boost::regex::emacs





It seems you need REG_EXTENDED rather than REG_BASIC then.
– Wiktor Stribiżew
Jul 2 at 16:35


REG_EXTENDED


REG_BASIC









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

api-platform.com Unable to generate an IRI for the item of type

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?