I need advice for how to create a REGEX in the best way (with as little code as possible). Suppose I have a list (that I don't know it's length before the running time) of Strings, say:
List<String> words = Array.asList("a","b","c");
I want to create this REGEX for example: (a|b|c).*
Is a loop necessary for this? Is there a way to do this in one line?
Thanks
words.stream().anyMatch(text::startsWith).