Powershell Tutorial Online


What is Regular Expression (REGEX)?
A regular expression is an object that describes a pattern of characters.
let see example on - how to use regular expressions in PowerShell scripts.

Example 2: Search for specific Text/string Although searching text can be done using contains function in powershell, but if we want to do some more operation in powershell then we must need to use REGEX. Lets work on matching text :
Inserting the entire regex match into the replacement text allows a search and replace to insert text before and after regular expression matches without really replacing anything.
It similar to comparing string javascript or any language in .NET Framework.
Let's see example to check a string contains expected character or substring by applying script such as the one below:

    #Search String in powershell with Regex
    [Regex]::IsMatch("I love powershell.","powershell")

Let's see example 2: Serach for digits
One can place any kind of regular expression they wish in place of, "powershell" to do the search. Let's see example of a regex search:

    #Digit Search with Regex
    [Regex]::IsMatch("powershell contains 1000 of commands.","[0-9]")

Let's see example 2: Serach for digits