Main Content

String Find

Return index of first occurrence of pattern string

  • Library:
  • Simulink / String

  • String Find block

Description

TheString Findblock returns the index of the first occurrence of the pattern stringsubin the text stringstr.

Ports

Input

expand all

String in which to find pattern (sub), specified as a scalar.

Data Types:string

Pattern to be found in string (str), specified as a scalar.

Data Types:string

Output

expand all

Position index of the found pattern, specified as a positive integer scalar.

  • 如果块does not find the pattern, it returns-1.

  • If thesubparameter is empty (""), the block returns1, indicating that it matched the beginning of the searched string.

Data Types:int8|int16|int32

Parameters

expand all

Output data type. The type can be inherited, specified directly, or expressed as a data type object such asSimulink.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.

  • 通过反向传播继承:继承— Use data type of the driving block.

Click theShow data type assistantbuttonto display theData Type Assistant, which helps you set the data type attributes. SeeSpecify Data Types Using Data Type Assistantfor more information.

Programmatic Use

Block Parameter:OutDataTypeStr
Type:character vector
Values:'Inherit: Inherit via internal rule'|'Inherit: Inherit via back propagation'|'int8'|'int16'|'int32'|''
Default:'Inherit: Inherit via internal rule'

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 R2018a