Regular Expressions 101

Community Patterns

XWiki: Decrease headings level

0

Regular Expression
ECMAScript (JavaScript)

/
^([^\S\r\n]*)(=+)(=)(.+?)(?:(=+)(=)([^\S\r\n]*))?$
/
gm

Description

Makes 2nd level headings the 1st level etc. This comes handy when for example creating a new page from a part of an existing XWiki page.

While this regex could also try to beautify (normalize) the headings at the same time, better use a dedicated regex for that.

Submitted by pbodnar - 3 years ago