Article 5R2WE Deleting a word in variable not knowing if it will be capitalized or not

Deleting a word in variable not knowing if it will be capitalized or not

by
pedropt
from LinuxQuestions.org on (#5R2WE)
in this text :

Quote:
I Think John went to the JOHN house
i can use :
Code:var1="I Think John went to the house"
var2=$(echo "$var1" | sed 's/\<JOHN\>//g' | sed 's/\<John\>//g')
echo "$var2"On this next code will fail because the Capitalized john is not in variable .
Code:var1="I Think John is fine"
var2=$(echo "$var1" | sed 's/\<JOHN\>//g' | sed 's/\<John\>//g')
echo "$var2"However if in next text the 2nd john does not show up then how can i write the code for the 2 options no matter if one of them does no show up in variable?latest?d=yIl2AUoC8zA latest?i=zf2wFziOlzE:RLsDgfyVm-g:F7zBnMy latest?i=zf2wFziOlzE:RLsDgfyVm-g:V_sGLiP latest?d=qj6IDK7rITs latest?i=zf2wFziOlzE:RLsDgfyVm-g:gIN9vFwzf2wFziOlzE
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments