Replace text and regular expressions: Difference between revisions

Created page with "Confuses me every time, so hoping to leave example this time. Special:ReplaceText allows use of regular expressions, see [https://www.mediawiki.org/wiki/Extension:Replac..."
 
mNo edit summary
Line 3: Line 3:
[[Special:ReplaceText]] allows use of regular expressions, see [https://www.mediawiki.org/wiki/Extension:Replace_Text#Using_regular_expressions their documentation].  
[[Special:ReplaceText]] allows use of regular expressions, see [https://www.mediawiki.org/wiki/Extension:Replace_Text#Using_regular_expressions their documentation].  


Example:
===Simple Example===
*Page has <code>abcdefghi</code>
*Page has <code>abcdefghi</code>
** Original text: <code>abcdef(.*)hi</code> ''ie want it to match the "g"''
** Original text: <code>abcdef(.*)hi</code> ''ie want it to match the "g"''
** Replacement text: <code>wx$1yz</code> ''ie want it to put the matched string between wx and yz''
** Replacement text: <code>wx$1yz</code> ''ie want it to put the matched string between wx and yz''
*results in <code>wxgyz</code>
*results in <code>wxgyz</code>
=== 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)


[[Category: Wiki Usage]]
[[Category: Wiki Usage]]