Extract a raw on my clipboard

Hi, I want use autopilot function with a clipboard content:

John DOE
99 rue la pompe
45600 Le Mas
FRANCE
Johndo@xmail.com
+3360000000

How can I extract the content "raw by raw" with extractregex and use {key:tab} to autofill a form ?

Thanks for your help.

Greg

Hi @Gregory_DE_SANTIS - welcome to the forum.

I'm assuming that the content you copied into your clipboard is exactly as you shared it here-specifically with regards to line breaks. If that's the case, here's how you can do it:

{note: preview=no}
{clipboard="John DOE
99 rue la pompe
45600 Le Mas
FRANCE
Johndo@xmail.com
+3360000000"}

{list=split(clipboard, "\n")}
{endnote}
{note}
This is the content broken up into a list:
{=list}
{endnote}

{=list[1]}{key:tab}{=list[2]}{key:tab}{=list[3]}{key:tab}{=list[4]}{key:tab}{=list[5]}{key:tab}{=list[6]}

In the example above I defined the data to be able to show you how it works in practice.

Here's another version that will use your cliipboard data once you copy it into your dashboard:

{list=split({clipboard}, "\n")}
{endnote}
{note}
This is the content broken up into a list:
{=list}
{endnote}

{=list[1]}{key:tab}{=list[2]}{key:tab}{=list[3]}{key:tab}{=list[4]}{key:tab}{=list[5]}{key:tab}{=list[6]}

If you want, you can also assign variable names to be able to re-use the data.

{note: preview=no}
{clipboard="John DOE
99 rue la pompe
45600 Le Mas
FRANCE
Johndo@xmail.com
+3360000000"}
{list=split(clipboard, "\n")}
{name=list[1]}
{address1=list[2]}
{address2=list[3]}
{country=list[4]}
{email=list[5]}
{phone=list[6]}
{endnote}
{note}
This is the content broken up into a list:
{=list}
{endnote}

The contact is {=name}, residing at {=address1}, {=address2}, {=country}. Contact details are {=email} or {=phone}.

3 Likes

Hi Cedric !

A big THANKS! It's exactly that I'm looking for.

Last question, can I split "45600 Le Mas":

45600
Le Mas.

Zipcode = 45600
City = Le Mas

Regards,

Greg

Hi @Gregory_DE_SANTIS,

Sure thing. Here's a way to do it:

{note: preview=no}
{text="45600 Le Mas"}
{list=split(text, " ")}
{zipcode=list[1]}
{city=join(slice(list, 2), " ")}
{endnote}
{=zipcode}
{=city}

Here's what's happening:

First, I'm splitting the contents of the text variable by spaces. This gives me the list that I very imaginatively called list (such creativation, much wow :rofl:)

Next, I'm referencing the first item of that list with list[1] and putting it in the variable zipcode

Then, I use slice to take all of the list items from the second one onwards, join them again by a space, and then put them in the variable city.

This final bit is important because it covers scenarios where the city name might be just one word, or more than two words.

Hope this is clear enough. If you need further explanation, I'm happy to help :slight_smile:

1 Like

Thank you for this.

1 Like

Thanks @Cedric_Debono_Blaze

I'm sorry, I can't make it work in my use case.

On my clipboard I have:

John DOE
99 rue la pompe
45600 Le Mas
FRANCE
Johndo@xmail.com
+3360000000

In result I would have:

John DOE {key:tab} 99 rue la pompe{key:tab} 45600 {key:tab} Le Mas {key:tab} FRANCE {key:tab} Johndo@xmail.com {key:tab} +3360000000

I think I'm missing part of the formula :rofl:

Try this:

{values=extractregexall({clipboard},"(.)\n"); trim=yes}
{=values[1]}{key:tab}{=values[2]}{key:tab}{=extractregex(values[3],"\d
(.)")}{key:tab}{=extractregex(values[3],"(\d) .")}{key:tab}{=values[4]}{key:tab}{=values[5]}{key:tab}{=extractregex({clipboard},"\n(+\d)")}

@Dan_Barak1 & @Cedric_Debono_Blaze

With your help, I wrote my firts line of code, and it's work! The result:

{note: preview=no}
{clipboard={clipboard}}
{list=split(clipboard, "\n")}
{endnote}

{=list[1]}{key:tab}{=list[2]}{key:tab}{key:tab}{=extractregex(list[3],"\d+")}{key:tab}{=extractregex(list[3],"\D+")}{key:tab}{=list[4]}{key:tab}{=list[5]}{key:tab}{=list[6]}{key:tab}

many thanks!

Greg

2 Likes

@Gregory_DE_SANTIS brilliant! So glad you managed to nail it.

Hit us up anytime if you have more questions :slight_smile:

BTW, could you share what was missing in your first attempt? We're always looking for ways to make TB more intuitive. Maybe there was something about the process that wasn't immediately clear to you and we might be able to improve on it.