Problems With Smart Value
Asked by Marcelo Ignacio Cid Abud:

Hello, I am using the following smart value to capture the word that comes after Fiscalizador: {{issue.description.match("Fiscalizador: (.+)")}}, the funny thing is that if I "paste" that smart value in a Text Field (single line) Jira interprets it as a kind of color (Clarify that Fiscalizador: will always have a number after it, ex: Fiscalizador: 12389). And if I paste this in the comments it simply pastes the number of this value. In summary If we take as an example the case of Fiscalizador: 1234 In a Text Field (single line) format field it will tell me 1234{color} In the comments it will show me 1234 I need to know if I am doing something wrong or if it is something specific to Jira. My intention is that only 1234 appears (it only happens to me with numbers![Captura2.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/347137i8F98AE557C12691B/image-size/large?v=v2&px=999 "Captura2.PNG")![Captura3.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/347138i616759FE84157D71/image-size/large?v=v2&px=999 "Captura3.PNG")![Captura1.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/347139iA03F8DC5DB78E648/image-size/large?v=v2&px=999 "Captura1.PNG")


Answers:
author: Manoj Gangwar
body: Hi [@Marcelo Ignacio Cid Abud](/t5/user/viewprofilepage/user-id/5000599)

Assuming the text you need is in a custom field called `Description`, and you want to capture what follows "Fiscalizador:":

{{issue.Description.split("Fiscalizador:").last.split(" ")\[0\]}}

This splits the description text by "Fiscalizador:", then takes the last part of that split result and further splits it by spaces, capturing the first word.

If you want to see the result for testing, you can use the "Log action" to output the captured value.  
The captured value is: {{issue.Description.split("Fiscalizador:").last.split(" ")\[0\]}}  

Or you might use this value to populate another field or take some other action in your rule.

comments: author: Marcelo Ignacio Cid Abud
body: [@Manoj Gangwar](/t5/user/viewprofilepage/user-id/4484987) Hi, thanks for the quick response. I'm going to try what you're telling me, but I'll leave you the images associated with my problem anyway hahaha


author: Marcelo Ignacio Cid Abud
body: I have this error  
Error rendering smart-values when executing this rule:  
Failed to get value for issue.Description.split("Fiscalizador:").last.split(" ")\[0\]: {{issue.Description.split("Fiscalizador:").last.split(" ")\[0\]}}


author: Manoj Gangwar
body: Could you please test the smart values?

{{issue.description.match("Fiscalizador: (\\\\d+)")}}

OR  

{{issue.description.match("Fiscalizador: (\\\\d+)")\[0\]}}

this one cleans up any special characters or formatting tags before inserting the value.

{{issue.description.match("Fiscalizador: (\\\\d+)")\[0\].replace("{color}", "")}}


author: Marcelo Ignacio Cid Abud
body: Nice, the first option {{issue.description.match("Fiscalizador: (\\\\d+)")}} is good :D


author: Marcelo Ignacio Cid Abud
body: [@Manoj Gangwar](/t5/user/viewprofilepage/user-id/4484987) One last question, what happens in the case of words? How does the formula vary? I was looking and if I extract a phrase I still get the phrase {color}


author: Manoj Gangwar
body: If you want to extract words or phrases after "Fiscalizador:", you can adjust the regular expression to allow letters, spaces, and possibly other characters.

{{issue.description.match("Fiscalizador: (\[\\\\w\\\\s\]+)")}}

\\\\w matches any word character (letters, digits, and underscores).

\\\\s matches spaces (to handle multiple words).

The + ensures it matches one or more of these characters.


Tags: cloud

jira-cloud