FindReplace Method

Build 1501 on 14/Nov/2017  This topic last edited on: 27/Sep/2016, at 12:22

Description

Searches the current text for a str1 and replaces it with str2, using options, specified in str3.

Syntax

Text.FindReplace (str1, str2, str3)

str1        

text string to be searched

str2

substitution string

str3

options for the retrieval:

U[+/-] = activates/deactivates case sensitivity

G[+/-] = activates/deactivates retrieval in entire

B[+/-] = activates/deactivates retrieval backwards

S[+/-] = activates/deactivates retrieval inside selection

T[+/-] = activates/deactivates jump of the cursor on found element

W[+/-] = activates/deactivates whole word match

P[+/-] = activates/deactivates replacement without the confirmation

A[+/-] = activates/deactivates replacement of all the occurrences

Return value

Error code

Examples

Use custom scripts to replace or delete special characters, tags and formatting. For special character codes, see the table on the bottom of this topic.

To replace in text all tags such as >head 20<, >headline<, with the >body< tag, use the following script:

Text.FindReplace (chr(1) & "head", chr(1)+"body"+chr(2), "G+S+W-U+B-P-T+A+")

To add a start tab after each ¶ in text (except for the first paragraph), use the following script:

Text.FindReplace (chr(6), chr(6)+chr(4), "G+S+W-U+B-P-T+A+")

To replace three spaces with a tab, use the following script:

Text.FindReplace (chr(32)+chr(32)+(chr32), chr(9), "G+S+B-P-T+A+")

To delete from text all tags such as >head 20<, >headline<, use the following script:

Text.FindReplace (chr(1) & "head", "", "G+S+W-U+B-P-T+A+")

To delete from text all tags, use the following script:

Text.FindReplace (chr(1), "", "G+S+W-U+B-P-T+A+")

To replace in text all bolds with bold italics, use the following script:

Text.FindReplace (chr(1) & "bd 1", chr(1) & "bd 1" & chr(2)+chr(1) & "it 1" & chr(2), "G+S+W-U+B-P-T+A+")

Text.FindReplace (chr(1) & "bd 0", chr(1) & "bd 0" & chr(2) & chr(1) & "it 0" & chr(2), "G+S+W-U+B-P-T+A+")

To replace in text all bold italics with italics, use the following script:

Text.FindReplace (chr(1) & "bd 1" & chr(2) & chr(1) & "it 1" & chr(2), chr(1) & "it 1" & chr(2), "G+S+W-U+B-P-T+A+")

Text.FindReplace (chr(1) & "bd 0" & chr(2) & chr(1) & "it 0" & chr(2), chr(1) & "it 0" & chr(2), "G+S+W-U+B-P-T+A+")

 

Special character

Code

Const

Tag bracket >

chr(1)


Tag bracket <

chr(2)


Start table ¦

chr(4)

StartTab

Table column

chr(9)

Tab

Last tab row

chr(8)

LastStartTab

Line break ¬

chr(5)

Ret

Paragraph break

chr(6)

HardRet

Bell @

chr(7)

Bell

Remarks

The above codes apply only on Find and FindReplace methods. If you're using the standard Instr function to find content in a string, populated by Text.TedGetTxt method, the codes are different: see GetTxt Method.

Context

Text designer commands

See also

Find, FindNext, FindDlg, FindReplaceDlg