# Can this be done using TB/Regex

**URL:** <https://community.blaze.today/t/can-this-be-done-using-tb-regex/29288>\
**Category:** Questions and Help\
**Created:** [May 25, 2023, 9:17am UTC](https://community.blaze.today/t/can-this-be-done-using-tb-regex/29288 "2023-05-25T09:17:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndyPage](https://community.blaze.today/user_avatar/community.blaze.today/andypage/32/6515_2.png) [@AndyPage](https://community.blaze.today/u/AndyPage)\
**Post date:** [May 25, 2023, 9:17am UTC](https://community.blaze.today/t/can-this-be-done-using-tb-regex/29288/1 "2023-05-25T09:17:44Z")

</div>

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.

```auto
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}

---

<div class="post-metadata">

**Author:** ![VinodGubbala](https://community.blaze.today/user_avatar/community.blaze.today/vinodgubbala/32/3615_2.png) [@VinodGubbala](https://community.blaze.today/u/VinodGubbala)\
**Post date:** [May 25, 2023, 9:41am UTC](https://community.blaze.today/t/can-this-be-done-using-tb-regex/29288/2 "2023-05-25T09:41:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![AndyPage](https://community.blaze.today/user_avatar/community.blaze.today/andypage/32/6515_2.png) [@AndyPage](https://community.blaze.today/u/AndyPage)\
**Post date:** [May 25, 2023, 9:49am UTC](https://community.blaze.today/t/can-this-be-done-using-tb-regex/29288/3 "2023-05-25T09:49:43Z")

</div>

@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.
