$regsubex

From Scriptwiki
Jump to: navigation, search

Performs a regular expression match, like $regex, and then performs a substitution using subtext.

$regsubex([name], text, re, subtext)

Subtext is evaluated during substitution and can be an identifier.

Subtext can also contain special markers where

  • \0 = number of matches
  • \n = match number
  • \t = match text
  • \a = all match items
  • \A = a non-spaced version of \a

Returns text result.

Example

$regsubex(<p style="font-size: 18px;">Example text.</p>,/<[^>]+>/g,)

The above regular expression can be used to strip any HTML tags using $regsubex, returning the stripped text.

See Also