this syntax returns an array with a word key.
I want the return value in this form but I want to search for a word that may or may not contain parentheses (with values in between).
"hello(some text and line breaks)"
What is the syntax for this?
will match words that can optionally be directly followed by a parenthesized text. Nested parentheses are not allowed.
\w+ # Match alnum characters
(?: # Match the following (non-capturing) group:
\( # literal (
[^)]* # any number of characters except )
\) # literal )
)? # End of group; make it optional
or if your regex engine defaults parentheses to normal character