how can i write the java program with wildcard like "%" "_"

A

alicecuee

Dear All,
I would like to write a java program with user input string with
regular express like "%" and "-" and query it in SQL.

How can i write the program with string support that kinds of wildcard?

Thanks
 
R

Roedy Green

How can i write the program with string support that kinds of wildcard?

See http://mindprod.com/jgloss/main.html

about passing awkward characters through the command line.

You might choose a character that does not already have meaning to the
command processor e.g. ~

SQL has the LIKE % feature. All you have to do is compose a suitable
query.

If you want to find files yourself that match some wildcard criteria,
you need to learn about FilenameFilters, File, File.list,
File.isDirectory.

See http://mindprod.com/jgloss/file.html

You might be interested in my RegexFilter. See
http://mindprod.com/products1.html#FILTER

With it you configure the filter with a regex describing the files you
want.
 
M

Mike Schilling

Dear All,
I would like to write a java program with user input string with
regular express like "%" and "-" and query it in SQL.

How can i write the program with string support that kinds of wildcard?

If you mean that you want your program to do matches with SQL-like
wildcards, the simplest thing will be to translate them into regexp-style
wildcards.
 
A

Alan Krueger

I would like to write a java program with user input string with
regular express like "%" and "-" and query it in SQL.

Perhaps you should describe exactly what these characters should mean.
I'm familiar with "%" in SQL, but have no idea what "-" should mean.

If you're going to query those in SQL, do you want to mimic this
behavior in Java or do you want to use the behavior implemented by your
SQL database? The approach to these would be very different.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top