mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-07-20 02:44:23 +00:00
c13f04d838
* add m flag to search-replace operator and add tests * update documentation * Update test-filters.js * Update test-filters.js * Update search-replace Operator (Examples).tid * Fix "Hello There" title (HelloThere)
33 lines
1.1 KiB
Plaintext
33 lines
1.1 KiB
Plaintext
created: 20201107112846692
|
|
modified: 20201118103305351
|
|
tags: [[Operator Examples]] [[search-replace Operator]]
|
|
title: search-replace Operator (Examples)
|
|
type: text/vnd.tiddlywiki
|
|
|
|
\define myregexp() e|o
|
|
|
|
\define myregexp2() ^(?!Unlike).*$
|
|
|
|
\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]]""" >>
|
|
|
|
To replace everything but a match using a regular expression and the ''multiline'' (m) flag:
|
|
`\define myregexp2() ^(?!Unlike).*$`
|
|
<<.operator-example 5 """[[HelloThere]get[text]search-replace:gm:regexp<myregexp2>,[]]""">>
|
|
|
|
{{How to remove stop words}}
|