My regex for displaying everthing after “(” :
echo "apples (orange) (plum)" | sed -re 's/^.+\(//'
Output : plum)
Expected output :orange) (plum)
How can I catch the first occuring character instead of the last ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
. matches any character, therefore sed watches the last bracket in the line.
Therefore
.mathes(and^[^(]+\(mathesapples (orange) (.So you need to use
[^(]*to not match any(at all as you suggest.