Currently I'm trying to use sed with regex on Solaris but it doesn't work.
I need to show only lines matching to my regex.
sed -n -E '/^[a-zA-Z0-9]*$|^a_[a-zA-Z0-9]*$/p'
perl -ne 'print if /^(a_)?[a-zA-Z0-9]*$/' input.txt
a_ one-or-zero times, so optionally. It may or may not be there.
(a_) also captures the match, what is not needed. So you can use
(?:a_)? instead. The
() only group what is inside (so
? applies to the whole thing), but not remember it.