Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
ECMAScript (JavaScript)

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

Description

Makes 1st level headings the 2nd level etc. This comes handy when for example making an extra chapter from a part of an XWiki page.

By-design, this regex also beautifies (normalizes) the headings syntax (like this regex).

Submitted by pbodnar - 3 years ago