Post

2 followers Follow
0
Avatar

User input variables - trailing spaces

I have created a "Find & Replace" Custom Action that asks a user for two text strings, and replaces one with the other in the selected Work Item names. That works OK in its basic form.

If I want the user to be able to enter text strings that end with one or more spaces, how do I do it?

I don't know how to capture trailing input spaces in user input variables so that when used in the ReplaceString function, the spaces are taken account of. At the moment, if a user enters a string containing trailing spaces, they seem to get stripped off before the variable value is set.

Dave Sparrow Answered

Please sign in to leave a comment.

1 comment

0
Avatar

Hello Dave,

Usually in HTML &nbsp is used to encode non-breaking spaces. However, $Name is not a Rich Text field and does not support this. Therefore, a workaround is needed and I think I have found one for you:

In action: https://www.screencast.com/t/n3Un05ZdY82n

This finds all '&NBSP' in the inputted text and replaces them with 'THIS_IS_A_SPACE THIS_IS_A_SPACE'. Then it replaces all 'THIS_IS_A_SPACE' with NULL. '&NBSP' and 'THIS_IS_A_SPACE' can be changed to anything you like (something that would not appear in a usual work item name).

Formula used: RegexReplace(RegexReplace($Name, Find, RegexReplace(Replace, '&NBSP', 'THIS_IS_A_SPACE THIS_IS_A_SPACE', TRUE), TRUE), 'THIS_IS_A_SPACE', NULL, TRUE)

The formula is fully case sensitive, but that can be changed by changing TRUE arguments into FALSE.

Please let me know if this helps.

Roland Pumputis 0 votes
Comment actions Permalink