Using java to search data using part of a string in a Microsoft access database

I have this table

enter image description here

And I use the following code to extract data from my table which returns all English words, that its Kurdish word contains بةرز

targetText="بةرز"; try (PreparedStatement ps = conn.prepareStatement( "SELECT English,Kurdish FROM Info " + "WHERE Kurdish = ? " + "OR REGEXP_MATCHES(Kurdish, ?) " + "OR REGEXP_MATCHES(Kurdish, ?) " + "OR REGEXP_MATCHES(Kurdish, ?) ")) { ps.setString(1, targetText); ps.setString(2, "^[. ]*" + targetText+ "[ ]*[:،,]+[ .]*$"); ps.setString(3, "^[. ]*[:،,]+[ ]*" + targetText+ "[. ]*$"); ps.setString(4, "^[. ]*[:،,]+[ ]*" + targetText+ "[ ]*[:،,]+[ .]*$"); try (ResultSet rSet = ps.executeQuery()) { while (rSet.next()) { System.out.println(rSet.getString("English")); System.out.println(rSet.getString("Kurdish")); } } } 

So it works great, it prints all the English words that I want.
My problem is that when I get the corresponding Kurdish word, it does not print the full cell. He just prints بةرز,

For example, the output of the previous code should be:

 aesthete بةرز ، جوانىثةرست aether زوَر ناسك ، بةرز ، ثيروَز ، ئاسمانى affair بةرز 

But he is typing

 aesthete بةرز aether بةرز affair بةرز 

What can I do to get the result I want?

Please note that I am using UCanAccess for my connection to the database,

+6
source share
1 answer

Tanks for everyone, I solved it with only a few changes in regx

 targetText="بةرز"; try (PreparedStatement ps = conn.prepareStatement( "SELECT English,Kurdish FROM Info " + "WHERE Kurdish = ? " + "OR REGEXP_MATCHES(Kurdish, ?) " + "OR REGEXP_MATCHES(Kurdish, ?) " + "OR REGEXP_MATCHES(Kurdish, ?) ")) { ps.setString(1, targetText); ps.setString(2, "^" + targetText+ "[ ]*(،)[.]*"); ps.setString(3, "[.]*(،)[ ]*" + targetText+ "$"); ps.setString(4, "[.]*(،)[ ]*" + targetText+ "[ ]*(،)[.]*"); try (ResultSet rSet = ps.executeQuery()) { while (rSet.next()) { System.out.println(rSet.getString("English")); System.out.println(rSet.getString("Kurdish")); } } } 
+1
source

All Articles