Can this be done using TB/Regex

Ok,I've been trying this for about an hr and I'm starting to think I may need to try another approach but as there are a lot of very clever people here with lots of TB experiance I thought I'd try my luck.

Basically I will have a block of text like this in my clipboard.

iCarly (ParamountPlus) - Thu 1st June 2023
With Love (Prime Video) - Fri 2nd June 2023
The Idol (HBO) - Sun 4th June 2023
Cruel Summer (Freeform) - Mon 5th June 2023
It's Always Sunny in Philadelphia (FXX) - Wed 7th June 2023
Never Have I Ever (Netflix) - Thu 8th June 2023

The format is TVSHOW (NETWORK) - DATE

I'd like to transform it so it looks like this.

#iCarly #WithLove #TheIdol #CruelSummer #ItsAlwaysSunnyinPhiladelphia #NeverHaveIEver

Basically we just want the TVSHOW part and then for that to be turned into a #hashtag. ie remove spaces and special characters and put a # at the front.

The hashtags are placed on a single line with a space between each hashtag.

eg

#hashtag1 #hashtag2 #hashtag3 #hashtag 4 etc etc

I've tried something like this but I'm getting myself into a pickle

{showslist=split({clipboard}, "\n")}
{repeat: len(showslist)}
#{=replaceregex(extractregex(showslist[index], "(.+?) (.+?) - .+"), " ", "")}
{endrepeat}

Does this snippet help?

{str="iCarly (ParamountPlus) - Thu 1st June 2023
With Love (Prime Video) - Fri 2nd June 2023
The Idol (HBO) - Sun 4th June 2023
Cruel Summer (Freeform) - Mon 5th June 2023
It's Always Sunny in Philadelphia (FXX) - Wed 7th June 2023
Never Have I Ever (Netflix) - Thu 8th June 2023"}
{showslist=split(str, "\n")}
{names=map(showslist, (s) -> extractregex(s, "(.+) \(.+\)"))}
{tags=map(names, (s) -> "#" & replaceregex(s, "[\s']", "", "g"))}
{=join(tags, " "); trim=yes}

  1. I split the string with new line
  2. Get the part of string before the braces in each line
  3. Replace spaces and quote with empty string and appended #
  4. Then joined the list with a space to print.
3 Likes

@VinodGubbala Thank you so much. That's brilliant.... seriously.

I'm going to learn about the map function now as that appears to be the part I was missing the most.

Once again, thank you.

1 Like