-6

In Java, I have a List of strings as follows:

List<String> OriginalList = Arrays.asList(
        "A=1,B=2,C=3",
        "A=11,B=12,C=13,D=15",
        "A=5,B=4,C=9,D=10,E=13",
        "A=19,B=20,C=91,D=40,E=33",
        "A=77,B=27,C=37");

I want to extract all values from this list that correspond to the "key" A. So, for example, I want to extract:

[1,11,5,19,77]

I thought I might be able to use a regular expression for this. What regular expression would I need to write?

Or is there a better solution to extract these values from a Java List?

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
code_gun
  • 1
  • 2
  • 3
    This post is under discussion on Meta: [What happened to own effort and general problem solving?](https://meta.stackoverflow.com/q/405141/4642212). – Sebastian Simon Feb 12 '21 at 18:54

0 Answers0