Core Function IndexNotOf

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
m (1 revision)
 
(5 intermediate revisions by one user not shown)
Line 15: Line 15:
 
=== needle ===
 
=== needle ===
  
The character to not find (If you pass a string here the first character of it will be used as the needle).
+
The string to not find.
  
 
=== pos ===
 
=== pos ===
Line 39: Line 39:
 
=== Return Value ===
 
=== Return Value ===
  
Success: Returns position of the first found character in the string that does not match the needle.
+
Success: Returns position of the first found string in the string that does not match the needle.
  
 
Failure: Returns -1.
 
Failure: Returns -1.
Line 52: Line 52:
  
 
<syntaxhighlight lang="sputnik">
 
<syntaxhighlight lang="sputnik">
 +
// Find characters
 
println(  IndexNotOf("The quick brown FoX", "T")  );
 
println(  IndexNotOf("The quick brown FoX", "T")  );
 +
// Find strings
 +
my $str = "The quick brown FoX";
 +
println(  IndexNotOf($str, "The q")  );
 +
println(  IndexNotOf($str, "The")  );
 +
println(  IndexNotOf($str, "TheTHE")  );
 +
my $a = IndexNotOf($str, "The ");
 +
println( substr($str, $a, 5)  ); // quick
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 58: Line 66:
  
 
<syntaxhighlight lang="sputnik">
 
<syntaxhighlight lang="sputnik">
 +
// Find characters
 
println(  IndexNotOf("The quick brown FoX", "t", 0, true)  );
 
println(  IndexNotOf("The quick brown FoX", "t", 0, true)  );
</syntaxhighlight>
+
// Find strings
 
+
Others
+
 
+
<syntaxhighlight lang="sputnik">
+
 
my $str = "The quick brown FoX";
 
my $str = "The quick brown FoX";
println(  IndexNotOf($str, "The q")  );
+
println(  IndexNotOf($str, "ThE q", 0, true)  );
println(  IndexNotOf($str, "The")  );
+
println(  IndexNotOf($str, "ThE", 0, true)  );
println(  IndexNotOf($str, "TheTHE")  );
+
println(  IndexNotOf($str, "TheTHE", 0, true)  );  
 
+
my $a = IndexNotOf($str, "THE ", 0, true);
my $a = IndexNotOf($str, "The q");
+
println( substr($str, $a, 5)  ); // quick
println( substr($str, $a - 1, 5)  );
+
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
[[Category:Core Function]]
 
[[Category:Core Function]]

Latest revision as of 12:37, 14 June 2015

IndexNotOf( <expression>, <needle>, <pos>, <case>, <count> )

Contents

Description

Reports the index of the first none occurrence of the specified string in the current string.

Parameters specify the starting search position in the current string and the type of search to use for the specified string.

expression

The string to use.

needle

The string to not find.

pos

Optional; Position to start the search from within the expression.

Default: 0

case

Optional; Case sensitive option

false = Case sensitive search

true = Case insensitive search

Default: false

count

Optional; The amount of characters to check before quitting the search

Return Value

Success: Returns position of the first found string in the string that does not match the needle.

Failure: Returns -1.

Remarks

None.

Example

Case sensitive

// Find characters
println(   IndexNotOf("The quick brown FoX", "T")   );
// Find strings
my $str = "The quick brown FoX";
println(   IndexNotOf($str, "The q")   );
println(   IndexNotOf($str, "The")   );
println(   IndexNotOf($str, "TheTHE")   ); 
my $a = IndexNotOf($str, "The ");
println( substr($str, $a, 5)  ); // quick

Case insensitive

// Find characters
println(   IndexNotOf("The quick brown FoX", "t", 0, true)   );
// Find strings
my $str = "The quick brown FoX";
println(   IndexNotOf($str, "ThE q", 0, true)   );
println(   IndexNotOf($str, "ThE", 0, true)   );
println(   IndexNotOf($str, "TheTHE", 0, true)   ); 
my $a = IndexNotOf($str, "THE ", 0, true);
println( substr($str, $a, 5)  ); // quick
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox