By the way, I also can use regexprep to replace all '|', by 'X', but I would like to replace a group of '|' by X:
expression = '[|]';
replace = 'X';
newStr = regexprep(str,expression,replace)
which returns:
str = vertcat(...
    "Whose woods XXXXXX these are I think I know.", ...
    "His house is in the village though;", ...
    "He will not see XXX me stopping here", ...
    "To 'X' watch his woods fill up with snow.")


