In this HackerRank Sed command #2 problem solution In this challenge, we will practice using the sed command to parse and transform text.

Task

For each line in a given input file, transform all the occurrences of the word 'thy' with 'your'. The search should be case insensitive, i.e. 'thy', 'Thy', 'tHy' etc. should be transformed to 'your'.

Input Format

A text file will be piped into your command via STDIN.

Output Format

Transform and display the text as required in the task

HackerRank Sed command #2 problem solution


Problem solution.

sed 's/thy/your/gi'


Second solution.

sed 's/\bthy\b/your/gi'


Third solution.

sed 's/\(^\| \)thy\( \|$\)/\1your\2/gi'


Fourth solution.

sed 's/\<[tT][hH][yY]\>/your/g'