Skip to main content
sylvio33
Known Participant
March 14, 2018
Question

insert formated text from clipboard after a specific character

  • March 14, 2018
  • 1 reply
  • 1226 views

Good day,

Is it possible to insert content of clipboard after a specific character with a script?

For example, I have a piece of specifically formatted text, which I need to insert after every "-"-sign in every text block of a document.

I imagine, first the cursor should be moved to the position after hyphen-sign and then the script should fire the command Paste.

Can somebody help me with code?

This topic has been closed for replies.

1 reply

Silly-V
Legend
March 15, 2018

Can you elaborate on what you mean by 'specifically formatted' ?

sylvio33
sylvio33Author
Known Participant
March 15, 2018

For example, a chemical formula with digits in subscipt, C12H22O11, or a piece of text with some characters in bold some in italic.

Classical Find/replace/regex scripts just replace characters and do not count on the formatting.

It seems, the simplest option to keep formatting is to paste already formatted text from the clipboard.

Silly-V
Legend
March 15, 2018

I was going to suggest looking here:

Re: RegExp search and replace, keep original text formatting

However, you may actually be looking to replace a string with text that may have multiple style ranges within the same text-match?