Main Content

String Count

Count occurrences of pattern in string

Since R2020a

  • String Count block

Libraries:
Simulink / String

Description

The String Count block counts the occurrences of the pattern (sub) in a string (str). If the input at sub matches part or all of the input at str, the block counts the occurrence as 1.

Ports

Input

expand all

String to search for the pattern in, specified as a scalar.

Data Types: string

String pattern to search for in string, specified as a scalar.

Data Types: string

Output

expand all

Number of times the string pattern was found in the string, str, returned as a scalar.

Data Types: int8 | uint8 | int16 | uint16 | int32 | uint32

Parameters

expand all

Case sensitivity for the string count:

on

Consider string case when counting found strings.

off

Do not consider string case when counting found strings.

Programmatic Use

Block Parameter: CaseSensitive
Type: character vector
Values: 'on' | 'off'
Default: 'on'

Output data type. The type can be inherited, specified directly, or expressed as a data type object such as Simulink.NumericType.

When you select an inherited option, the block exhibits these behaviors:

  • Inherit: Inherit via internal rule — Simulink® chooses a data type to balance numerical accuracy, performance, and generated code size, while taking into account the properties of the embedded target hardware.

  • Inherit: Inherit via back propagation — Use data type of the driving block.

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the data type attributes. See Specify Data Types Using Data Type Assistant for more information.

Programmatic Use

Block Parameter: OutDataTypeStr
Type: character vector
Values: 'Inherit: Inherit via internal rule' | 'Inherit: Inherit via back propagation' | 'int8' | 'uint8' | 'int16' | 'uint16' | 'int32' | 'uint32' | <data type expression>
Default: 'Inherit: Inherit via internal rule'

Category of data type, specified as Inherit, Built in, or Expression. For more information on using this parameter, see Specify Data Types Using Data Type Assistant.

Dependency

Clicking the Show data type assistant button enables this parameter.

Block Characteristics

Data Types

integer | string

Direct Feedthrough

yes

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

no

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2020a