"Fossies" - the Fresh Open Source Software Archive

Member "elasticsearch-6.8.23/docs/painless/painless-regexes.asciidoc" (29 Dec 2021, 1410 Bytes) of package /linux/www/elasticsearch-6.8.23-src.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format (assuming AsciiDoc format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field.

Regexes

Regular expression constants are directly supported. To ensure fast performance, this is the only mechanism for creating patterns. Regular expressions are always constants and compiled efficiently a single time.

Pattern p = /[aeiou]/

Pattern flags

You can define flags on patterns in Painless by adding characters after the trailing / like /foo/i or /foo \w #comment/iUx. Painless exposes all of the flags from Java’s Pattern class using these characters:

Character Java Constant Example

c

CANON_EQ

'å' ==~ /å/c (open in hex editor to see)

i

CASE_INSENSITIVE

'A' ==~ /a/i

l

LITERAL

'[a]' ==~ /[a]/l

m

MULTILINE

'a\nb\nc' =~ /^b$/m

s

DOTALL (aka single line)

'a\nb\nc' =~ /.b./s

U

UNICODE_CHARACTER_CLASS

'Ɛ' ==~ /\\w/U

u

UNICODE_CASE

'Ɛ' ==~ /ɛ/iu

x

COMMENTS (aka extended)

'a' ==~ /a #comment/x