• Intro Headers Instructions Macros Commands
Fork me on GitHub
    • Getting Started
      • Introduction
      • How to install bnd
      • Guided Tour Workspace & Projects
      • bnd / bndlib Features and JAR Wrapping Techniques
      • FAQ - Frequently Asked Questions
    • Concepts and Practices
      • Concepts
      • Background
      • Best practices
    • Build and Development
      • Build
      • Generating JARs
      • Versioning
      • Baselining
      • Service Components
      • Metatype
      • Contracts
      • Bundle Annotations
      • Accessor Properties
      • SPI Annotations
    • Dependency and Launching
      • Resolving Dependencies
      • Launching
      • Startlevels
    • Testing
      • Testing
      • Testing with Launchpad
    • Packaging and Distribution
      • Packaging Applications
      • JPMS Libraries
      • Wrapping Libraries to OSGi Bundles
    • Documentation and Tools
      • Generating Documentation
      • bnd CLI Commands
      • For Developers
      • Templates for Workspaces
      • Tips for Windows users
      • Tools bound to bnd
    • Reference Material
      • Reference
      • Headers
      • Instruction Reference
      • Instruction Index
      • Macro Reference
      • Macro Index
      • Plugins
      • External Plugins
    • Configuration and Troubleshooting
      • Settings
      • Errors
      • Warnings
  • indexof ';' STRING (';' LIST )*

    Prev Next
    Macro
    Find the index position of a value in one or more lists

    Summary

    The indexof macro searches for a value in combined lists and returns its 0-based index position, or -1 if not found.

    Syntax

    ${indexof;<value>;<list>[;<list>...]}
    

    Parameters

    • value - The value to search for
    • list - One or more comma-separated lists to search in

    Behavior

    • Combines all lists into one
    • Searches for exact match of value
    • Returns 0-based index of first occurrence
    • Returns -1 if value not found
    • Case-sensitive search

    Examples

    Find value in list:

    ${indexof;green;red,green,blue}
    # Returns: 1
    

    Not found:

    ${indexof;yellow;red,green,blue}
    # Returns: -1
    

    Search multiple lists:

    ${indexof;target;${list1};${list2}}
    

    Check if value exists:

    ${if;${matches;${indexof;test;${list}};-?[0-9]+};found;not-found}
    

    Use Cases

    • Finding element positions
    • Checking list membership
    • List searching operations
    • Conditional logic based on presence
    • Array indexing

    Notes

    • Returns integer index (0-based)
    • First occurrence only
    • Case-sensitive
    • Combines multiple lists before searching
    • See also: ${lastindexof} for last occurrence
    • See also: ${find} for substring search in strings

    See test cases in MacroTestsForDocsExamples.java

Prev Next
Search
    • Home