Quantcast
Channel: regex – Working Sysadmin
Browsing all 7 articles
Browse latest View live

Quick Tip: PowerShell Regex To Get Value Between Quotation Marks

If you’ve got a value like the following… [crayon-5a2288bc903bc397493980/] … that maybe came from the body of a file, was returned by some other part of a script, etc., and you just want the portions...

View Article



Quick Tip: Validate The Length Of An Integer

A little while ago, I fielded a question in the PowerShell Slack channel which was “How do I make sure a variable, which is an int, is of a certain length?” Turns out it’s not tooRead More...

View Article

Does A String Start Or End In A Certain Character?

Can you tell in PowerShell if a string ends in a specific character, or if it starts in one? Of course you can. Regex to the rescue! It’s a pretty simple task, actually. Consider the followingRead More...

View Article

Custom PSScriptAnalyzerRule – Function Capitalization

I’ve got a number of custom PSScriptAnalyzer rules that I sometimes run. A little while ago I uploaded them to GitHub to share with others. Today I’m going to walk you through the...

View Article

Using PowerShell To Split A String Without Losing The Character You Split On

Last week, I wrote a post on the difference between .split() and -split in PowerShell. This week, we’re going to keep splitting strings, but we’re going to try to retain the character that we’re...

View Article


PowerShell Regex Example: Incrementing Matches

In the PowerShell Slack, I recently answered a question along these lines. Say you have a string that reads “first thing {} second thing {}” and you want to get to “first thing {0} second thing {1}” so...

View Article

Regex Example: Strip Out HTML Tags

First and foremost, HTML is not regex friendly. You should not try to parse HTML in PowerShell, or using regular expressions unless you’ve lost some kind of bet or want to punish yourself for...

View Article
Browsing all 7 articles
Browse latest View live




Latest Images