• 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
  • matches STRING REGEX

    Prev Next
    Macro
    Check if a string matches a regular expression pattern

    Summary

    The matches macro tests whether a string matches a given regular expression pattern. Returns true if the entire string matches, false otherwise.

    Syntax

    ${matches;<string>;<regex>}
    

    Parameters

    • string - The string to test
    • regex - The regular expression pattern (Java regex syntax)

    Behavior

    • Tests if entire string matches the pattern
    • Returns boolean (true/false)
    • Uses Java regular expression syntax
    • Must match the entire string (implicit anchoring)

    Examples

    Check pattern match:

    ${if;${matches;v1.2.3;v[0-9]+\.[0-9]+\.[0-9]+};valid-version;invalid}
    

    Validate format:

    ${matches;com.example.api;com\.example\..*}
    # Returns: true
    

    Check numeric:

    ${if;${matches;${value};[0-9]+};is-number;not-number}
    

    Test package pattern:

    ${matches;${package};com\..*\.impl}
    

    Use Cases

    • Pattern validation
    • String format checking
    • Conditional logic based on patterns
    • Input validation
    • Package name filtering

    Notes

    • Uses Java regex syntax
    • Entire string must match (no partial matches)
    • Case-sensitive by default
    • For case-insensitive, use (?i) in pattern
    • See also: ${filter} for list filtering
    • See also: ${find} for substring search

    See test cases in MacroTestsForDocsExamples.java

Prev Next
Search
    • Home