select ';' LIST ';' REGEX
Macro
Summary
Filter a list to include only elements that match a regular expression. This macro is an alias for the filter macro.
Syntax
${select;<list>;<regex>}
Parameters
- list: Comma-separated list of elements to filter
- regex: Regular expression pattern to match against
Behavior
Returns a new list containing only the elements from the input list that match the specified regular expression pattern.
This macro is functionally identical to filter.
Examples
# Select items starting with "com."
packages = com.example.api, org.sample.impl, com.example.util
${select;${packages};com\..*}
# Returns: com.example.api,com.example.util
# Select files with specific extension
files = foo.jar, bar.txt, baz.jar
${select;${files};.*\.jar}
# Returns: foo.jar,baz.jar
# Select numbered items
items = item1, item2, other, item3
${select;${items};item\d+}
# Returns: item1,item2,item3
# Select packages matching pattern
-conditionalpackage: ${select;${packages};com\.company\.internal\..*}
Use Cases
- Package Filtering: Select packages matching a naming pattern
- File Selection: Filter file lists by extension or pattern
- Dependency Filtering: Select specific dependencies from a larger list
- Pattern Matching: Include only items matching a specific format
Notes
- This is an alias for the filter macro - they behave identically
- Uses Java regular expression syntax
- Elements are matched in their entirety (use
.*for partial matching) - The opposite operation is provided by reject or filterout
Related Macros
- filter - Identical functionality (primary name)
- reject / filterout - Exclude elements matching regex
- removeall - Remove specific elements from a list
- retainall - Keep only elements present in another list
TODO Needs review - AI Generated content
See test cases in MacroTestsForDocsExamples.java
