Index Any
Finds the index of the first occurrence of any character from a specified set of characters.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
info
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- String - The string to search in.
- Characters - A string containing the set of characters to search for.
Options
This node does not have configurable options.
Output
- Result - Index position of the first matching character (0-based), or -1 if none found.
How It Works
The Index Any node searches for the first occurrence of ANY character from the provided character set:
- 0-based indexing: First character is at index 0
- Finds earliest match: Returns position of whichever character appears first
- Case-sensitive: 'A' and 'a' are different characters
- Returns -1: If none of the characters are found
Unlike Index which finds a substring, IndexAny finds individual characters.
Usage Examples
Example 1: Find First Vowel
- String:
"Hello World" - Characters:
"aeiou" - Result:
1(first vowel 'e' at position 1)
Example 2: Find First Digit
- String:
"Order #12345" - Characters:
"0123456789" - Result:
7(first digit '1' at position 7)
Example 3: Find First Delimiter
- String:
"name:John,age:30" - Characters:
":," - Result:
4(first delimiter ':' at position 4)
Example 4: Find First Special Character
- String:
"Hello@World!" - Characters:
"@#$%!" - Result:
5(first special char '@' at position 5)
Example 5: No Match
- String:
"Hello" - Characters:
"xyz" - Result:
-1
Tips
- Useful for finding any of multiple possible delimiters
- Great for validation (checking if string contains unwanted characters)
- More flexible than Index when you have multiple possible characters
- Characters string order doesn't matter - earliest match wins
- Use for finding first whitespace, punctuation, or special character
- Case-sensitive - include both 'A' and 'a' if you want both
Common Errors and Solutions
Error: Returns -1 when characters should exist
- Cause: Case sensitivity - included 'A' but string has 'a'
- Solution: Include both cases in Characters, or convert string to lowercase first
Error: Returns unexpected position
- Cause: Different character matched than expected
- Solution: Check which character actually appears first in the string
Practical RPA Examples
Example: Validate No Special Characters
String: ${msg.username}
Characters: "!@#$%^&*()"
Result: If result == -1, username is valid (no special chars)
If result >= 0, username contains special characters
Example: Find First Number in Text
String: "Product ABC has 5 items"
Characters: "0123456789"
Result: 16 (position of '5')
Use: Extract numeric value from text
Example: Detect Invalid Filename Characters
String: ${msg.filename}
Characters: "/\\:*?\"<>|"
Result: If >= 0, filename contains invalid characters
Example: Find First Whitespace
String: "HelloWorld Test"
Characters: " \t\n\r"
Result: 10 (position of space)
Use: Detect word boundaries
Example: Parse Structured Data
String: "name=John;age=30"
Characters: "=;"
Result: 4 (first delimiter '=' found)
Use: Begin parsing key-value pairs
Example: Find First Vowel Position
String: "rhythm"
Characters: "aeiouAEIOU"
Result: -1 (no vowels - well, 'y' isn't counted)
String: "example"
Characters: "aeiouAEIOU"
Result: 0 (first vowel 'e' at start)
Use Cases by Category
Validation
- Check if password contains numbers:
"0123456789" - Check if text contains punctuation:
".,!?;:" - Validate no special chars:
"@#$%^&*()"
Parsing
- Find first delimiter:
",;:" - Find first whitespace:
" \t\n" - Find first bracket:
"([{<"
Text Analysis
- Find first uppercase:
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" - Find first digit:
"0123456789" - Find first vowel:
"aeiouAEIOU"