• Documentation
  • Workato Blog
  • Product Blog
  • Return to Workato
  • Login
  • Automation Institute
  • Documentation
  • Community Forums
New Topic
Discussions Recipe Building Formula Mode Questions
T

Thomas Winkler

started a topic about 2 years ago

How to replace parts of a string wich can be found between [ and ] within a text with .gsub

Hi, 


I have a titel of a task e.g. "[Project Alpha 20209] Initial Task" and I'd like to replace the part between [ and ] with a different content.


I tried with  

image


without success. It does not recognize the part between the brackets and does not replace anything at all.


I think there is maybe a problem with the REGEX within the find section. I already tried it in vain with different expressions. Any hints?


S

Sachin Dalmia

said about 2 years ago

Thomas, your regex is fine. It's just that you should use forward slashes to encapsulate your complex regex expression. I understand the docs can be a little confusing. I'll have it updated soon. 



/\[.*\]/

Moreover, you don't need to escape brackets to substitute. Here's a sample recipe that you can refer for this.

T

Thomas Winkler

said about 2 years ago

Dear Sachin, 


thank you for your valuable advice. With your help now I was able to code a nice piece of recipe.


PS: I had not dared to make the "find" section like this, because when I entered the code this area was colored red. It then immediately looks "wrong" at first glance. :-D



1 person likes this
Login to post a comment

Still can't find your solution?

Send us a ticket, we will try our best to assist you with your problem

Documentation
Developer's Library
Tutorials
eBooks
Product Hour
Product Blog
Workato Blog
Product updates
Customer Stories
© Workato 2022   Privacy   Terms   +1 (844) 469-6752
  • Documentation
  • Workato Blog
  • Product Blog
  • Solutions
  • Forums
  • Tickets
  • Log in
  • Return to Workato
Topic views count