I would like to remove the symbol "|" but only when it is at the beginning of a sentence (e.g., I want "|pediatrics" to become "pediatrics" but "pediatrics|clinical" should not be changed.
I tried
sub('[|[:alnum:]]','', "word")
which works well in the case where "|" is indeed at the beginning of the sentence, but removes the first letter when it is not present (i.e.,
sub('[|[:alnum:]]','', "|pediatrics")
returns pediatrics as desired but
sub('[|[:alnum:]]','', "pediatrics")
returns ediatrics...
Any help would be extremely valuable! Thanks in advance.