Remove numbers and special character from string elements in a list

I have following list.

def list = ['1.0 small', '2.0 big', '3.0 large']

I am trying to remove the numbers and the ‘.’ sign from the list elements.

I tried the following:

for (String el : list) {
    StringUtils.remove(el, ".").replaceAll("[0-9]", "").trim();
}

I am then printing the list but it prints the same with numbers and period sign. Does someone knows how to achieve this?

Please show us your code. Show us how you are printing it.

Like this…

for (String el: sizeOptionsSE) {
			StringUtils.remove(el, ".").replaceAll("[0-9]", "").trim();
			KeywordUtil.logInfo(el);
		}

In Java/Groovy, a String is immutable.

Have a look at this:

import org.apache.commons.lang3.StringUtils

import com.kms.katalon.core.util.KeywordUtil

def sizeOptionsSE = ['1.0 small', '2.0 big', '3.0 large']

for (String el: sizeOptionsSE) {
	StringUtils.remove(el, ".").replaceAll("[0-9]", "").trim();
	KeywordUtil.logInfo(el);
}

for (String el: sizeOptionsSE) {
	String s = StringUtils.remove(el, ".").replaceAll("[0-9]", "").trim();
	KeywordUtil.logInfo(s);
}