Institute for Networking and Security Research Department of Computer Science and Engineering Pennsylvania State University, University Park, PA
Systems and Internet Infrastructure Security
i i
Regular Expressions
- Prof. Patrick McDaniel
Regular Expressions Prof. Patrick McDaniel Fall 2016 Regular - - PowerPoint PPT Presentation
Systems and Internet i Infrastructure Security i Institute for Networking and Security Research Department of Computer Science and Engineering Pennsylvania State University, University Park, PA Regular Expressions Prof. Patrick McDaniel
Institute for Networking and Security Research Department of Computer Science and Engineering Pennsylvania State University, University Park, PA
i i
replace tool
in shell scripts, as a text editor feature, or as part
pattern
“Y and X” for any X, Y
the middle stands for
which looks for literal strings
expressions
languages’ flavors
expression, and file(s) are the files to search
lines
directories
contain “fgh”
contain “lmn”
the whole string
characters from the shell!
“gry”
“ah”
where the second, fourth, and sixth letters are “o”
least 23 characters long
next slide
contain a, e, i, o, u in that
between)
(i.e., optional)
necc?ess?ary
in that order and at least
an empty argument
match?
where all the rest of the letters are a, n, or s
type with ASDFJKL
type with AOEUHTNS!
can make with A through E
letters long (hint: pipe the
q, followed by something
ranges
digit: ???
q, followed by something
ranges
digit: [^0-9]
the entire group
followed by “ach” one or more times, followed by e
with the first, is an e
search your code for the expression int \* to find integer pointers
same characters again
from the start of the regex
four-character sequence repeated immediately
$ sed -r 's/([a-z]+) and ([a-z]+)/\2 and \1/g'
your regex-fu
tutorial puzzles and works up