I need help on getting a regex expression to get a string between ( )
Use your email () to login.
I need a regex expression that would get the email out. I can't seem to do it. Is it because of the ( )?
11 Answer
Depending on the program you're writing your regex for you'll have to use appropriate escaping. For example, with sed:
ts@xenon:~> echo 'Use your email () to login.' | sed -e 's/.*(\(.*\)).*/\1/'
ts@xenon:~>In this case, the backslashes will escape the parentheses after them into metacharacters that extract the matched string between them into the metavariable \1 while the parentheses not preceded by a backslash will be matched literally.