Replace/delete special characters, tags and text by scripting

Build 1501 on 14/Nov/2017  This topic last edited on: 26/Oct/2016, at 21:03

Use VBScripts 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)

 

not used

chr(3)

 

Start tabulation ¦

chr(4)

StartTab

Tabulation

chr(9)

Tab

Last tab row

chr(8)

LastStartTab

Line break ¬

chr(5)

Ret

Paragraph break

chr(6)

HardRet

Bell @

chr(7)

Bell

Notes

The Const column contains the internal constants used in Text.InsSpecialChar command to create the special characters. The constants are defined in the add-ins.

See also InsTedText Method when you need to insert characters by modifying text string, and GetTxt methodwhen you are putting a Ted4 text in a string.