Hello
I want to implement this function:
boolean check(String str,String exp)
that gets a string, and an expression and see if it mathches.
But (!), according to a format by '*' (maybe similar to the SQL LIKE statement, but with * instead of %).
Examples of tests of this function that should work:

boolean b3=check("55-210.txt", "55*"); // starts with 55
assertEquals(b3,true);
boolean b5=check("f1.txt", "*.txt"); // ends with *.txt
assertEquals(b5,true);
b=check("897", "8*8*"); // 8...8...
assertEquals(b,false);

I don't mind, and even prefer to use existing external jars that can help, like Jakarta RegExp, JOSQL, and such.

Thanks in advance

Recommended Answers

All 3 Replies

Have you tried if statement(s) trying to see if the expression contains a * (using substring) and then have a boolean like isAtFront that is true if the * is at the front and false if the * is at the back

actually you are right when there is only one '*', Maybe I will keep it simple, and implement it only for one.

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.