SE Michigan PowerShell Users Group - Regex Part1
-
Upload
southeast-michigan-powershell-script-club -
Category
Technology
-
view
1.637 -
download
1
Transcript of SE Michigan PowerShell Users Group - Regex Part1
Matt JohnsonSE Michigan PowerShell Script Club
Introduction Simple Pattern Searches Simple Pattern Examples Introduction to Regular Expressions Closing
Used with both operating system commands and PowerShell commands.
Using cmd.exe we used “*” and “?”. With PowerShell we get a few more options.
Also work with -like and –notlike
Simple Pattern Wildcards
Turns out this is a basic form of regular expressions
Wildcard Description
* Any number of characters
? Exactly one character
[xyz] One of the specified characters
[x-z] One of the characters in the specified area
Dir *.txt
Dir [li]*
$ip = 192.168.23.1If ($ip –like “*.*.*.*”) {“Valid”} Else {“Invalid”}
From Wikipedia: “Regular expressions provide a concise and flexible means for identifying strings of text of interest, such as particular characters, words, or patterns of characters.”
Found in some programming / scripting languages, editors and utilities.
Programming Languages: PowerShell, Perl, .NET languages, C++
Editors: Visual Studio, emacs
Utilities: grep, Power Grep
Websites:◦ http://www.regular-expressions.info/
Websites:◦ www.regexlib.com
Websites:◦ MSDN Regex Class
Books◦ Mastering Regular Expressions by Jeffrey Friedl◦ Regular Expressions Cookbook by Jan Goyvaerts,
Steven Levithan
Applications◦ Rad Software Regular Expression Designer◦ http://www.radsoftware.com.au
Applications◦ Ultrapico Expresso 3.0◦ http://www.ultrapico.com/expresso.htm
Applications◦ The Regex Coach◦ http://weitz.de/regex-coach
PowerShell and Regular expressions PowerShell and .NET’s Regex class Regular Expression Examples
Contact Me:Matt Johnson, GSEC, MCSEEmail: [email protected]:
http://www.packetcrazy.com/blogSocial Sites: mwjcomputing
- Twitter, Friendfeed, Facebook