I’m looking to simply pull some quoted text out of a function call and was wondering if I could get some help with regex?
The string would look something like this:
‘MyFunction(“MyStringArg”);’
I would, essentially, like to scan a file for any lines that call ‘MyFunction’, and then capture the string literal within the quotes.
Follow-up Question
How would I go about avoiding commented lines with this?
Update
I was able to solve my problem with:
MyFunction\s*\(\s*"(.*?)\"\s*\)\s*;
Thanks @devyndraen and everyone for your help!
I’m not sure what kinds of requirements for formatting you have, so I included the assumption that there could be any amount of space in the normal programming places there could be some.
The resultant string will be in the \1 backreference.
http://rubular.com/r/qVsaqJS6gJ