Examples

Example

Java Code
final String yaml = """
        Number:
            Integer: [ '\\d+' ]
            Real: [ '${Integer}\\.${Integer}' ]
        
        Currency:
            USD: [ '\\$', 'USD' ]
            EUR: [ '€', 'EUR' ]
        
        Money: [ '${Currency}${Number}', '${Number} ${Currency}' ]
        
        Percent: [ '${Number}%' ]
        """;

final String input = """
        Order total: $32.50 (tax: 12%)
        Refund issued: €45.67
        Discounts applied: 10% and 5%
        """;

final ExpressoMatcher matcher = Expresso.compile(yaml).matcher(input);
while (matcher.find()) {
    System.out.println(matcher.group());
}
Output
$32.50
12%
€45.67
10%
5%

Last updated