Search code examples
regexlinuxlibtool

libtool-regexp: OR-concatenate options


I fail with quite a simple problem with a regular expression for libtool-option -export-symbols-regex:

My library has to export several functions that start with "foo_" and "bar_". But the command line option

-export-symbols-regex '(foo_|bar_)'

seems to be wrong, only the foo_-functions are exported.

So: how should this regular expression look like to export both?

Thanks!


Solution

  • Your regex (foo_|bar_) does not ensure the substrings foo_ and bar_ appear at the start of the function name.

    You should include the ^ start of string anchor.

    ^(foo_|bar_)
    

    Regular expression visualization

    More informatin about the start of string anchor can be found at regular-expressions.info/anchors