Split text from Clipboard into different variables

Hi there!

I’ve been trying to solve this for days now but I could’t find a solution. My regex attempts failed miserably…

Basically what I want to achieve is this:
Go from this input (including line breaks and more than 2 tags)

<description>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. _

It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</description>

to saving the text between the tags in variables.

So VAR_NAME = “Max”; VAR_DESCRIPTION = “Lorem Ipsum …”

Can anyone point me in the right direction?

I was trying to use the “Search Variable Using Regular Expression” function but couldn’t get the text between the tags to match.


Edit: And it doesn’t have to be html tags. I just want to be able to pass multiple variables (including some with multiple lines) into KM.

EDIT 2: Thanks a lot for the answers! I ended up finding a solution with JMichaelTXs Regex Code.

I’m afraid I don’t have the time to help you devise a full solution at the moment, but I can point you in the right direction with this regex, which should capture any text between two brackets as per your tags example:



One question: are the names of the tags or variables always consistent? Like, will the text you’re working with always have a <name> or <description> tag (or any other tags as long as they’re always named the same thing)? Because if they do, that makes getting their contents into the right KM variables considerably easier.

1 Like

Thanks! Will test as soon as I get home.

So to clarify my objective: I’m wanna use KM for setting meta tags for some files in a program. Therefore I plan on collect the info beforehand - author, cover image (url), description etc - then copy everything into the clipboard, open the program and let KM do the filling in for me so that I don’t have to manually copy paste them individually.
Long story short: the naming of the tags and variables is up to me as I’m not parsing data from an external source. Is that what you meant?

Is multi-line a factor in the OP’s attempts not being successful?

Give the example source string you provided, this should work, using a RegEx of:

For info and RegEx details, see https://regex101.com/r/YdmDfl/1

[quote="pat, post:1, topic:7572"]
And it doesn't have to be html tags. I just want to be able to pass multiple variables (including some with multiple lines) into KM.

This RegEx is very specific to the HTML tags used in your example.
If you want a more general solution, then you will need to provide us with the range of source data to be used.