Main Content

startsWith

Determine if strings start with pattern

Description

example

tf = startsWith(str,pat) returns 1 (true) if str starts with the specified pattern, and returns 0 (false) otherwise.

example

tf = startsWith(str,pat,IgnoreCase=true) ignores case when determining if str starts with pat.

Note

Only Stateflow® charts that use MATLAB® as the action language support the startsWith operator.

Examples

expand all

h = "Hello, world!"
pat1 = "H"
pat2 = "h"
x = startsWith(h,pat1)
x2 = startsWith(h,pat2)

Stateflow chart that uses the startswith operator in a state.

Results from stateflow chart that uses the startswith operator in a state.

h = "Hello, world!"
pat1 = "H"
pat2 = "h"
x = startsWith(h,pat1,IgnoreCase=true)
x2 = startsWith(h,pat2,IgnoreCase=true)

Stateflow chart that uses the startswith operator in a state.

Results from stateflow chart that uses the startswith operator in a state.

Limitations

Version History

Introduced in R2021b