Equinox Online Help - Language Reference - A to Z

Home

Search / SearchNext

Applies to
SyntaxSearch StringExpression, PatternExpression, StartItem, LengthItem [, SearchExpression, NoSlidingSearchExpression] SearchNext StringExpression, PatternExpression, StartItem, LengthItem [, SearchExpression, NoSlidingSearchExpression]
Action[Statement] Searches for a string within a string.
ScopeUsable anywhere.
Notes

This statement searches for the string PatternExpression, inside StringExpression. The SearchNext statement uses the start parameter returned by a previous Search statement as the place to start searching from.

You can include the following special characters in PatternExpression:

  • * Wildcard: matches any number of characters
  • ? Wildcard: matches any single character
  • \n Matches an end of line character
  • \t Matches a tab character
  • \* Matches an asterisk character
  • \? Matches a question mark character
  • \\ Matches a back-slash character

The fifth argument, SearchExpression, can take one of the following values:

  • 0 Exact case and recognises special characters
  • 1 Any case and recognises special characters
  • 2 Exact case and ignores special characters
  • 3 Any case and ignores special characters
  • 14 Backwards sliding search, exact case and ignores special characters
  • 15 Backwards sliding search, any case and ignores special characters

If you omit SearchExpression, then by default the value 0 is used.

Exact case dictates the two strings must be the same case to match. Any case ignores the case differences.

Special characters sometimes occur in the target, for example back-slash occurs in operating system file paths. You can choose to ignore special characters in the PatternExpression, and treat them as literal characters.

Sliding search means, for example, that searching for “asdf” in “this asdf string” returns true (This example uses value 6).

All searches are sliding searches by default. If NoSlidingSearchExpression is supplied and is nonzero, the search only succeeds if the whole of the string is matched.

If PatternExpression is not matched, SysError is set to 1. Otherwise it is set to zero, the position of its first character is returned in StartItem, and the length of the matching portion of StringExpression is returned in LengthItem (if it is included). This is useful if you include wildcard characters in PatternExpression.

CategoryString handling
See Also ChrList, Chrs, Compare, Fill, IsNumber, Left_Function, Len, Match, Maxlen, Mid_Function, Remove, Replace, Right_Function], SetLen, SetMaxLen, SortOrder, SubstituteData
Example

This example finds each occurrence of the letter h in the string, starting from the end.

int st, ln
string s

s = "Here's one hello and here's another hello in the same string"

Search s, "h", st,ln, 15

while not SysError
print st, ln
SearchNext s, "h", st,ln, 15
end while