Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Regular Expression Example
- # \d matches only digits
- # This code will only match the first digits it finds and stop after that
- "abcd345fhbfhnfrj123" -match "\d+"
- # This code will match the all digits
- "abcd345fhbfhnfrj123" -match "(\d+)"
- # Using the regular expressions will always populate the $Matches variable
- $Matches
- # Matching an email address
- "first.lastname@company.com" -match "([a-z]+)\.[a-z]+@[a-z]+\.com"
- # Match only letters
- "abcdefghijkmnopqrstuvwxyz0123456789" -match "\w+[^\d]"
- # Parse Log Files and return the files with a specific IP (-SimpleMatch Parameter treats the string as non regex query)
- Get-Childitem -Recurse -Include *.log | select-string -Pattern "10.211.55.30" -SimpleMatch -List
- # Parse Log Files and return the files with a specific IP (RegEX)
- Get-Childitem -Recurse -Include *.log | select-string -Pattern "\s(\d{1,3})\."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement