Please enable JavaScript to view this site.

Knowledge Base

Navigation: Scripting Language > Functions

findstring

We've made some changes. Use 'Ctrl-F5' to clear your browser cache.
Scroll Prev Top Next More

Returns the position of a given substring in a string.

 

Supported Product: FDTD, MODE, DEVICE, INTERCONNECT

 

Syntax

Description

pos = findstring(s,s1);

Returns the position of the first instance substring s1 in s. If s1 is not found in s, it returns -1.

pos = findstring(s,s1,p0);

Returns the position of the first instance substring s1 in s, starting at position p0. If s1 is not found in s, starting from p0, it returns -1.

 

Example

These are some examples of how to find a substring in a string.

?findstring("test12test34","test34");

result: 

7

 

?findstring("test12test34","test");

result: 

1

 

?findstring("test12test34","test",4);

result: 

7

 

?findstring("test12test34","test",8);

result: 

-1

 

See Also

Functions, length, substring, replace, replacestring, str2num, num2str, splitstring, lower, upper, toscript

Copyright Lumerical Inc. | Privacy | Site Map