Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: Regex: match a word stem plus an optional suffix from a group

by Your Mother (Archbishop)
on Jul 21, 2022 at 02:40 UTC ( [id://11145622]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Regex: match a word stem plus an optional suffix from a group
in thread Regex: match a word stem plus an optional suffix from a group

You should also escape interpolated stuff in regexen. \Q${wordstem}\E in this case. If you don’t, you can end up with really confusing bugs and, depending on Perl version, a malicious regex that can be a DoS attack. I would encourage you to use /x to improve readability. Something like–

/ \b \Q${stem}\E (?: s | 's | n )? \b /xi

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11145622]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-03-28 22:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found