Search last comment for a string?

I have some automation that is being triggered by JQL. However I only want it to trigger if the LAST comment on the issue contains a string (Lets say “test”).

Is there a way to do this with scriptrunner? I found:
https://docs.adaptavist.com/sr4js/latest/features/jql-functions/included-jql-functions/comments

But this doesnt appear to be able to search the last comment for text, but only by the author, role, etc…

Just wanting to know if there was something I am missing.

Thank you!