Let's say I have a text file with these contents:

color1 = yellow.$199 * 100
         color2 =         red.$1 * 22
         myNextColor =  green.$3
         whatsNext = blue.$$
         oneMore =     orange.$

I need to be able to get an array like this:

colorsInFile = ["yellow","red","green","blue","orange"]

In python, the regex for picking this out is:

r'=\s*(\w+)\s*\.\$'

What's the java equivalent?
Thanks for the help :)

i hope this help you , and the same for the others

public static void main(String[] args) {
      //  System.out.println("aaaa");
        
        String source = "color1 = yellow.$199 * 100";

        Pattern p = Pattern.compile("([a-zA-Z]+\\d+?) = (([a-zA-Z]+)(.)*) ");

        Matcher m = p.matcher(source);

        while (m.find()) {
            // will return yellow 
            System.out.println(m.group(3));
           
        }
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.