bh has asked for the wisdom of the Perl Monks concerning the following question:

I have had trouble finding much documentation about regular expression matching in XS modules. I would like to do 1) simple matching ($var =~ /^string/) and 2) simple substitutions ($var =~ s/test/task/g;). Can someone post or point me to some examples of this using XS code? Thank you

Replies are listed 'Best First'.
Re: regular expressions in XS modules
by BrowserUk (Patriarch) on Jul 11, 2016 at 17:54 UTC

    See perlreapi, particularly exec().


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: regular expressions in XS modules
by Cow1337killr (Monk) on Jul 12, 2016 at 02:12 UTC

    I agree with Anonymous Monk.

    Feel free to post your proposed regular expression. The other Perl Monks can give you tips on speeding it up.

    There is a wealth of information on the Internet, in books, in videos from Perl conventions, in threads at the Perl Monks website, etc., regarding regular expressions and how to make them faster and more powerful.

    But, if your only recourse is to resort to coding in XS, the other Perl Monks may advise you of that, too, after viewing your specific application.

    I used to work for a guy and I would ask him "How do you do this?" Often, he would respond: "What are you trying to do?"

    Re^3: Perl XS may be of interest to you.

Re: regular expressions in XS modules
by Anonymous Monk on Jul 11, 2016 at 23:15 UTC
    Are you sure about that? Are you sure calling a sub YourSub from xs isn't all you need?