Relative Content

Tag Archive for regexstring-matching

How to match a function but exclude object methods without negative lookbehind

I’m trying to write a regex that matches every occurrence of some_function(...), but it should not match when it’s part of an object method like my.some_function(...) or if it is a substring of another function, i.e., myname_some_function(...). The function can appear in various contexts, including within another function call, after whitespace, or standalone:

How to match a function but exclude object methods without negative lookbehind

I’m trying to write a regex that matches every occurrence of some_function(...), but it should not match when it’s part of an object method like my.some_function(...) or if it is a substring of another function, i.e., myname_some_function(...). The function can appear in various contexts, including within another function call, after whitespace, or standalone: