Issue
I'm trying to get this regex to work egrep '[a-zA-Z\]\[]*' <<< '{[dict]}'
Both of these work
% egrep '[a-zA-Z\]]*' <<< '{[dict]}'
{[dict]}
% egrep '[a-zA-Z\[]*' <<< '{[dict]}'
{[dict]}
but for some reason having both [ and ] together produces no matches
Also if I add -o
I get
% egrep -o '[a-zA-Z\]]*' <<< '{[dict]}'
d
i
c
t]
Solution
From the documentation it says that if you want to match ]
, it needs to be the first character in the group.
What you're trying, modified to conform to that rule, works:
$ egrep '[]a-zA-Z\[]*' <<< '{[dict]}'
{[dict]}
Answered By - Richard Dodson Answer Checked By - David Goodson (WPSolving Volunteer)