Match boundary between whitespace characters and non-whitespace characters
creates a pattern
that matches the start or end of a run of whitespace characters.
pat = whitespaceBoundary
whitespaceBoundary can be negated using the
operator. When negated,
~whitespaceBoundary matches the boundary between
any two characters except at the start or end of a run of whitespaces.
whitespaceBoundary to divide a string along whitespace boundaries. This pattern matches boundaries between a whitespace character and a non-whitespace character.
Create a pattern that matches any whitespace boundaries.
txt = "123 abc .?! def 456"; pat = whitespaceBoundary ;
replace to insert "|" characters at the matched boundaries.
ans = "123| |abc| |.?!| |def| |456"
"end" options for
whitespaceBoundary to match the boundary between whitespaces and non-whitespace characters.
Create a string that contains several different character types. Create a pattern that matches any characters between an
"end" boundary of whitespaces and a
txt = "123 abc .?! def 456"; pat = whitespaceBoundary("end") + wildcardPattern(1,inf) + whitespaceBoundary("start");
Extract the pattern.
boundaries = extract(txt,pat)
boundaries = 3x1 string "abc" ".?!" "def"
~ operator to negate
whitespaceBoundary. This matches boundaries between two characters when both are whitespace characters or neither is a whitespace character.
Create a string that contains several different character types. Create a pattern that matches a negated
txt = "123 abc .?!"; pat = ~whitespaceBoundary;
replace to insert
"|" characters to show where ~
boundaries = replace(txt,pat,"|")
boundaries = "|1|2|3 a|b|c .|?|!|"
type— Boundary type
Boundary type, specified as
A whitespace is any character or series of characters that represent horizontal or vertical space. When rendered, a whitespace character does not correspond to a visible mark, but typically does occupy an area on a page. Common whitespace characters include:
Significant Whitespace Character
Standard whitespace character,
Narrow no-break space
For more information, see Whitespace character.