Clipboard paragraph formating

Hi, given a sentence (from clipboard), how can I format it to have new layout as in the example?
I suppose the coma (,) may be part of the solution.

Original:
Biologia II - $500, Física y Química II - $500, Historia II - $1090, Carlomagno. El padre de Europa - $984, para Santiago Soler de 2do. Año.

Output (needed):
Biologia II - $500,
Física y Química II - $500,
Historia II - $1090,
Carlomagno. El padre de Europa - $984,
para Santiago Soler de 2do. Año.

Best regards,
Martin

Something like this should work Martin:

{=replace({clipboard}, ",", ",\n")}

It worked Perfect, thank you. It helps me a lot!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

One more help please, How can I Sum al the values with the $
Biologia II - $500,
Física y Química II - $500,
Historia II - $1090,
Carlomagno. El padre de Europa - $984,

Something like this would work. Replace the clipboard variable with {clipboard} when you actually use it.

{clipboard="Biologia II - $500, Física y Química II - $500, Historia II - $1090, Carlomagno. El padre de Europa - $984, para Santiago Soler de 2do. Año."}
{=sum(filter(splitregex(clipboard, "\$(\d+)"), (x, i) -> isEven(i)))}

@martinhgps, here's a breakdown of the solution that @scott created, to help explain the concepts better.

Hope this helps. If you have any questions, hit me up anytime and I'll be happy to explain further :slight_smile:

THANK YOU! It works as expected!!!
Question: Which is the command that tells the snippet to exclude the rest of the content of the data? How does it know to use only numbers? What happens if the content is "$500.45alabama" and not "$500.45 alabama", Does work with decimals?
Example
Biologia II - $500**, Física y Química II -** $500**, Historia II -** $1090**, Carlomagno. El padre de Europa -** $984**, para Santiago Soler de 2do. Año."**
Best regards!!!!!

You can support decimal numbers by changing the regular expression in splitregex() to this:

{clipboard="Biologia II - $500.21, Física y Química II - $500.3, Historia II - $1090, Carlomagno. El padre de Europa - $984, para Santiago Soler de 2do. Año."}
{=sum(filter(splitregex(clipboard, "\$(\d+\.?\d*)"), (x, i) -> isEven(i)))}

The "\d" tells it to match numbers so it won't match the "a" in "alabama" or other letters or things like spaces.

Thank you! Really I want to spread the mouth that you and team are allways ready to give quick answers. Thank you!!!!

1 Like