Hy

I want to validate expression as such:

AO:10
EM:1
IO:102
AO:SA
EM:SA,AKA,LLMN

so on...

I'm noe to Regex and i came out with the following function:

public void checkFormat(String line) {
        String expression = "^[ACEILMNOU.]{2}+\\B[:]{1}+\\w{2,4}+";
        Pattern subscriptionExpretion = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);
        Matcher matcher = subscriptionExpretion.matcher(line);

        if(matcher.matches()) {
            System.out.println("matches " + line);
        } else {
            System.out.println("doesn't match " + line);
        }
    }

witch doesn't work... anyone has a clue on how to make it work?

Thank you

Edited 4 Years Ago by ~s.o.s~: Added data inside code tags to prevent smiley interpolation

You need to break up the regex you have posted and explain your reasoning behind putting the constructs which are there in your regex. Also, instead of posting "sample data" for the pattern you can looking for, it would be much for helpful for your own sake to frame the requirements in words. An e.g. the regex should accept any two alphabets followed by a colon and one or more digits.

I solved my problem, but not with regex, thanks anyway

This question has already been answered. Start a new discussion instead.