Next: , Previous: , Up: sed   [Contents][Index]

6.7.2 Defining Sed Databases

The definition of a sed databases requires a single argument: the s-expression to be applied. For example:

database dequote sed 's/<(.*)>/\1/g'

Be sure to properly quote the expression, especially if it contains backreferences. It is preferable to use single quotes, to avoid duplicating each backslash in the expression, as shown in the example below. If the expression itself contains single quote, you may either use double-quotes to quote the entire expression:

database foo sed "s/'utf8'(.*)/u8_\\1/"

or use escaped single quotes outside of quoted expression (a technique familiar for shell programmers):

database foo sed 's/'\''utf8'\''(.*)/u8_\1/'

All options valid for module initialization (see sed module) may also be used in database declarations. When used so, they take precedence over module initialization options. For example, the following database definition uses basic case-insensitive regular expressions:

database bar sed noextended noicase 's/test(\([^)]\))/\1/g'