Skip to content

strjust

strings · scripts/strings/strjust.m

: str = strjust (s)
: str = strjust (s, pos)

Shift the text of each row of a character matrix to one side.

pos is "left", "center" or "right" (the default) and is matched without regard to case. The width of the matrix is unchanged: the blanks that padded each row are moved to the other side, or split between both sides for centring. Null characters count as blanks and come back as spaces.

strjust (["x   "; "xy  "; "xyz "])
     ⇒ 
        "   x"
        "  xy"
        " xyz"