Stripping away characters with ReplaceAll in Katalon Studio
After reading in text, it’s a common need to replace some of the text or get rid of it entirely. There may be a need to remove a comma, a dollar sign, take off a parenthesis etc. While ReplaceAll is a simple command, there are some tricks to it, especially when using special characters like $ and (). As an example, almost all the values on the site I’m working with have $ , and % in the number. In order to manipulate them, those characters need to be removed. It’s common that after a GetText command, there is a ReplaceAll command. Since the $ is a special character, the Groovy interpreter needs to know it’s coming by using a \ before the $ To remove a $ and , from a dollar figure, the following ReplaceAll will work. tempText=tempText.replaceAll(“[\$,]”, “”) – The $ must have a single \ in front. The same will be true for other characters like […]
Recent Comments