Freigeben über


RegEx for Splitting Hairs

Here's some hairs...

 

ths4tmxkvx

 

Wrong hairs!

 

Here is the intended hairs...

 
$Hairs = 'PD112345D123456F£45637'

 

How do we split $Hairs down to just show numbers? RegEx and -Split to the rescue.

 
$Hairs -split "\D+"

 

capture189

 

Here we are using anything that isn't a digit as the divider. Simples.