replacing trailing space using regex

Hello,

I am trying to replace a string with a trailing space with an special character #. I am using pub:String:replace service to do it

inString : AR (spaces before and after)
searchString : / (space)
replaceString : #
useRegex : True.

This above things replace all the spaces before and after AR with #. What should be the input of replaceString if I have to just replace the trailing part with #. Expected ouput is AR######

Thanks in advance.

Jiten

Try " $" without the quotes.

The regex supported in IS is described in Apppendix B of the Developer User’s Guide.

That’s nice excercise!

For input=" AR “, output=” AR#" solution is obvious … but for " AR###" is not so straightforward :slight_smile: (doing it in one pub.string:replace)

Is that a statement or a question?

Another way to replace ending spaces is with look-ahead token " (?= *$)".