-
The order of precedence of operators in POSIX extended regular expression is as follows.
- Collation-related bracket symbols
[==]
,[::]
,[..]
- Escaped characters
\
- Character set (bracket expression)
[]
- Grouping
()
- Single-character-ERE duplication
*
,+
,?
,{m,n}
- Concatenation
- Anchoring
^
,$
- Alternation
|
- Collation-related bracket symbols
-
Some regular expression patterns are defined using a single leading backslash, e.g.,
\s
,\b
, etc. However, since special …
Regular Expression in Bash
It is suggested that you use Python script instead of Shell script as much as possible.
If you do have to stick with Shell script,
you can use =~
for regular expression matching in Bash.
This make Bash syntax extremely flexible and powerful.
For example,
you can match multiple strings using …
Regular Expression in Python
Online Regular Expression Tester
The Python module
re
automatically compiles a plain/text pattern usingre.compile
and caches it, so there's not much benefit to compile plain/text patterns by yourself.Some regular expression patterns are defined using a single leading backslash, e.g.,
\s
,\b
, etc. However, since special characters (e.g.,\
) need to be escaped in strings in most programming languages, you will need the string"\\s"