Deleting a word in variable not knowing if it will be capitalized or not
in this text :
Quote:
Code:
var1="I Think John went to the house" Code:
var1="I Think John is fine" |
Depends on how specific the tests are - if only those 2, use alternation. If any variation of jOHn might arise, use a case-insensitive directive. See the doco from the GNU site or "info sed"; the manpage doesn't go this detail.
|
There was a recent thread on case-insensitive matching in sed.
|
Thanks
|
It's useful in general to read up on the topic of "regular expressions ('regexes')."
|
Of course on something so trivial, you don't even need something like sed:
Code:
x='I Think John went to the JOHN house' |
And if you want to store it in a new variable, you can use a simple assignment
Code:
var1='I Think John went to the JOHN house' |
All times are GMT -5. The time now is 11:09 AM. |