1.2k questions

1.4k answers

361 comments

339 users

Categories

Sidebar
0 votes
6.9K views
by joe-d-8335 (180 points)
I see a documented function for StringUtils.ContainsAny but not much information beyond the signature. Does the searchString have to be characters, or can it be whole strings? Does it match by RegEx or something else?

2 Answers

0 votes

StringUtils.ContainsAny will search for any character or number in the search characters list or array of characters. If any one of the characters is found then a boolean value of true will be returned.

StringUtils.contains('abc1', '1') = true
StringUtils.containsAny("zzabyycdxx",['z','y']) = true
StringUtils.containsAny("zzabyycdxx", "zy")    = true

 

by gary-t-8719 (15.1k points)
by joe-d-8335 (180 points)
How about a set of strings instead of a string of chars?

StringUtils.containsAny("zzabyycdxx",["za","zb"])
by mike-r-7535 (13.8k points)
@joe-d, I don't think that will work.  According to https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/StringUtils.html , containsAny allows for the following parameters: (string, string) or (string, char[]).  There is no containsAny(string, string[]).
0 votes

The search parameter of containsAny must be either an array of characters, or a single string.  This is according to the StringUtils documentation.

None of the StringUtils functions use regular expressions.  Regular expressions can be used with Java Strings or Javascript Strings in QIE.

by mike-r-7535 (13.8k points)
...