# space boundary (?(?<= \S) # if there is a nonspace character left (?! \S) # then there must be no space character right | (?= \S) # else there must be a space character right )