Table of Contents
Regular Expression Operators reference
\<symbol>
(no special)
^
, $
, .
[..]
, [^...]
(...)
, |
*
, +
, ?
{n}
, {n,}
, {n,m}
,
[:alpha:]
, [:alnum:]
, [:digit:]
, [:xdigit:]
[:lower:]
, [:upper:]
[:blank:]
(spaces and tabs) [:space:]
(space)
[:print:]
(printable, including spaces)
[:graph:]
(printable and visible, excluding spaces)
[:punct:]
(punctuation), [:cntrl:]
(control)
Print only the regex matched part howto
- Use
substr()
with RSTART
and RLENGTH
, which are provided by match()
.
awk 'match($0, /regex/) { print substr($0, RSTART, RLENGTH) } ' file