How to assign output of substr funtion to a variable

I am completely new to terraform.

I have a tag line which picks project name of my current gcp project which am working.
tags= []

I need to pass that project name output given by tags block to my substr function to extract first 4 digits of project name.
value = “$(substr(var.tags,0,3))”

I need the output of substr funtion to save in a variable

What are you needing to use that value for?

It sounds like you are either wanting to use an output or a local variable, depending on the usage.