Find

Looks for a substring inside a specified string.

Syntax

Find(string1, string2)

Parameters

Parameter

Type

Description

string1

string

The string where we look for a substring

string2

string

The substring that we are trying to find

Return

Looks for a string string2 inside the string string1, returns a number - 1-based position of the first character of string2 in the string1. Returns zero is string2 is not found.

Note

In Python, use find() method of a string object: https://www.tutorialspoint.com/python/string_find.htm.

Examples

Python

import nex
# this script selects only the neurons that have "05" in their name
doc = nex.GetActiveDocument()
nex.DeselectAll(doc)
for i in range( 1, nex.GetVarCount(doc, "neuron") + 1):
    name = nex.GetVarName(doc, i, "neuron")
    if name.find("05") >= 0:
        nex.SelectVar(doc, i, "neuron")

NexScript

% this script selects only the neurons that have "05" in their name
doc = GetActiveDocument()
DeselectAll(doc)
for i=1 to GetVarCount(doc, "neuron")
    name = GetVarName(doc, i, "neuron")
    if Find(name, "05")> 0
        SelectVar(doc, i, "neuron")
    end
end