mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-08-27 19:42:50 +00:00
![saqimtiaz](/assets/img/avatar_default.png)
* Docs for is[draft] * Better error handling for suffixes * Docs for search-replace operator * Added tests for search-replace operator * Docs for toggle operator
25 lines
841 B
Plaintext
25 lines
841 B
Plaintext
created: 20201107112846692
|
|
modified: 20201107113536230
|
|
tags: [[Operator Examples]] [[search-replace Operator]]
|
|
title: search-replace Operator (Examples)
|
|
type: text/vnd.tiddlywiki
|
|
|
|
\define myregexp() e|o
|
|
|
|
\define names() (\w+)\s(\w+)
|
|
|
|
Replace one string with another:
|
|
<<.operator-example 1 """[[The quick brown fox jumps over the lazy dog]search-replace[dog],[cat]]""">>
|
|
|
|
Replace all matches of a regular expression:
|
|
|
|
`\define myregexp() e|o`
|
|
<<.operator-example 2 """[[Hello There]search-replace:g:regexp<myregexp>,[]]""">>
|
|
|
|
Replace all matches of a string irrespective of case:
|
|
<<.operator-example 3 """[[Hello There]search-replace:gi[H],[]]""">>
|
|
|
|
You can also use regular expression capture groups in the replacement string:
|
|
|
|
`\define names() (\w+)\s(\w+)`
|
|
<<.operator-example 4 """[[John Smith]search-replace::regexp<names>,[$2,$1]]""" >> |