Bird
0
0

You want to replace all vowels in the string 'Automation' with '*'. Which command correctly does this using -replace?

hard📝 Application Q15 of 15
PowerShell - Regular Expressions
You want to replace all vowels in the string 'Automation' with '*'. Which command correctly does this using -replace?
A'Automation' -replace '[aeiou]', '*' -all
B'Automation' -replace 'aeiou', '*'
C'Automation' -replace '[aeiou]+' '*'
D'Automation' -replace '[aeiou]', '*'
Step-by-Step Solution
Solution:
  1. Step 1: Understand the pattern for vowels

    The pattern '[aeiou]' matches any single vowel character in the string.
  2. Step 2: Check the replacement command

    'Automation' -replace '[aeiou]', '*' uses the correct regex pattern and syntax to replace each vowel with '*'. 'Automation' -replace 'aeiou', '*' treats vowels as a literal string, not a pattern. 'Automation' -replace '[aeiou]+' '*' lacks the comma between pattern and replacement, causing a syntax error. 'Automation' -replace '[aeiou]', '*' -all uses an invalid '-all' flag.
  3. Final Answer:

    'Automation' -replace '[aeiou]', '*' -> Option D
  4. Quick Check:

    Use character class '[aeiou]' for vowels [OK]
Quick Trick: Use square brackets for character sets in regex patterns [OK]
Common Mistakes:
  • Not using brackets for character sets
  • Trying to pass multiple arguments without comma
  • Adding unsupported flags like '-all'

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes