0

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

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by liran
0

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

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.