Skip to main content
  • New archived content: Talend MDM, Talend Data Catalog 8.0, and Talend 7.3 products reached their end of life in 2024. Their documentation was moved to the Talend Archive page and will no longer receive content updates.
Close announcements banner

Checking the position of a specific character or substring, within a string

The INDEX routine is easy to use along with a tJava component, to check whether a string contains a specified character or substring:

System.out.println(StringHandling.INDEX("hello world!", "hello"));
System.out.println(StringHandling.INDEX("hello world!", "world")); 
System.out.println(StringHandling.INDEX("hello world!", "!")); 
System.out.println(StringHandling.INDEX("hello world", "?"));

The routine returns a whole number which indicates the position of the first character specified, or indeed the first character of the substring specified. Otherwise, -1 is returned if no occurrences are found.

The result is 0, 6, 11, and -1 in the Run view.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!