Replace text and regular expressions

From CCMDB Wiki
Jump to navigation Jump to search

Confuses me every time, so hoping to leave example this time.

Special:ReplaceText allows use of regular expressions, see their documentation.

Simple Example

  • Page has abcdefghi
    • Original text: abcdef(.*)hi ie want it to match the "g"
    • Replacement text: wx$1yz ie want it to put the matched string between wx and yz
  • results in wxgyz

Example with line end anchor

Not sure why it had to be used, but without it the rest of the words didn't get matched.

  • Before text (title): (T) Wrist Joint
  • O: \(T\) (.*)$ the $ shows end of line
  • R: $1 (T)
  • After text: Wrist Joint (T)

Example to match variations with inconsistent capitalization (and I think inconsistent spacing)

Two other cents, to find any and all variations. (assuming one template parameter per line) Search: "(?i)(\n) *\| *tItEl *=.*\n" Replace: "$1"

Related articles

Related articles: