Sed Regular Expressions: Difference between revisions
Jump to navigation
Jump to search
Line 4: | Line 4: | ||
* [[Regular Expressions]] | * [[Regular Expressions]] | ||
=Special Characters (need to be escaped in regular expressions)= | =<span id='Special_Characters_.28need_to_be_escaped_in_regular_expressions.29'></span>Meta-Characters - Special Characters (need to be escaped in regular expressions)= | ||
/ | / |
Revision as of 17:05, 7 June 2018
Internal
Meta-Characters - Special Characters (need to be escaped in regular expressions)
/ " $ # unescaped signifies end of line ^ # unescaped signifies the beginning of a line ! [ ] : * # zero or more . # dot
Non-Special Characters (do not need to be escaped in regular expressions)
< > ( ) ! - { } + # this is interesting, I thought '+' is a meta-character, more experimentation necessary.
Grouping
Use \( and \) for grouping. Parentheses must be escaped to be interpreted as grouping separator.
Examples
Match everything except space:
[^ ]*
.*
seems to work too.
Words (digits, alpha, _):
sed -e 's/[0-9a-zA-Z_]*/THIS_WAS_A_WORD/g'
Blank spaces (spaces, tabs, newlines): \s does not seem to work.
Regular Expression Syntax
TO NORMALIZE across java Regular Expression Syntax, grep Regular Expression Syntax, sed Regular Expression Syntax.