try custom notations in Java online

Note: you have to enable Java in your browser in order to try custom notations interactively.

introduction

The myPatterns/Java library allows matching any Java object with a pattern written in any custom notation. However, there is a default, predefined, JSON-based notation, that is demonstrated on this page.

With respect to the strictly complying JSON syntax, we here admit a relaxed JSON syntax, in which simple field names can be written without quotes, and strings may be delimited by either single or double quotes.

The default matching notation is JSON patterns, an extension of (relaxed) JSON for filtering and decomposing data, in which:

demo

In the following applet: and press the match button. The resulting substitution (mapping variables to sub-data) will be shown below.

Note that the resulting substitution maps named variables to their values, and capturing groups (within regexes) to their matched substrings. Capturing groups are numbered starting from zero (if you want the substring matched by the whole regex as group number zero, enclose the whole regexp in a capturing group).

source

The source code of the above applet is here.
Last updated on 14/7/2010.