SNIPPET - Extract content from specific parts of the clipboard


#1

Hi all,

I've created a snippet that allows me to copy content from a document into my browser's clipboard using Ctrl+C, then:

  1. Extract a specific part of that content by dictating a start point and end point in that text
  2. Extract additional specific parts according to heading.

To try it out:

  1. Open this Google doc: https://docs.google.com/document/d/1PaR72CC9q1StY4kM4vxIkKLMvnVjckzvruiVfNpY4TA/edit?usp=sharing
  2. Highlight all of its contents (Ctrl+A)
  3. Copy it to the clipboard (Ctrl+C)

Now, run the snippet below and see what happens.

There are many ways you can use this. If you have any questions, please ask and we can figure out the answers together :slight_smile:

{note}

This is where I set the start and end points for my snippet to extract the content.

Start point: {formtext: name=beginning; default=start} <<< This is the string of text where you want the snippet to START extracting content

End point: {formtext: name=end; default=stop} <<< This is the string of text where you want the snippet to STOP extracting content

{section=extractregex({clipboard}, beginning & "([\D \S]+)" & end)}

=====================================

What you see below, is what is being extracted from your clipboard, starting from the text «{=beginning}» and ending at the text «{=end}»
{=section}

=====================================

Here I'm setting the variables I want to extract. The snippet gives me anything that follows (but not including) the text that I enter here, up until the next line break.

{note}Field 1:{endnote} {formtext: name=var1; default=Var1: }
{note}Field 2:{endnote} {formtext: name=var2; default=Var2: }
{note}Field 3:{endnote} {formtext: name=var3; default=Var3: }

{variable1=extractregex(section,""&{=var1}&" ([\w \S]+)")}{variable2=extractregex(section, ""&{=var2}&" ([\w \S]+)")}{variable3=extractregex(section, ""&{=var3}&" ([\w \S]+)")}

=====================================

{endnote}

{note}This is what will be printed (without the headings "Variable 1" etc){endnote}

{note}Variable 1:{endnote} {=variable1}
{note}Variable 2:{endnote} {=variable2}
{note}Variable 3:{endnote} {=variable3}