Advanced filtering in table

IoSonoPiero

Active Member
Licensed User
Longtime User
Hello,
I'm building a search function but I'm stalled on a particular request I've received. :BangHead:

Some users tell me they need to find in a populated table (not SQLite) words that contain at least a capitalized characters (the characters can be in every position of the word).

How can I accomplish this?
I have to use regular expressions?

I'm using for other simple search the table.Filter function.
Can .Filter and regular expressions be mixed up to give a powerful search function for table?

Or I have to choose ONE of the TWO way to do a search (or .Filter or regular expression)?

Thanks,
ghale
 

IoSonoPiero

Active Member
Licensed User
Longtime User
Well, the table can contain from few rows up to 1000 rows.

The problem is that users must search for any characters in the table, so I'm using .Filter method to filter table rows.

Some user ask me to implement a "capitalized word search", in which the table must shows words with at least a capitalized character in it.

The users can mix the search, for example they can search for words that are capitalized and that contains character "x" in them.

I'm thinking about regular expressions, but I don't have idea how to user .Filter with regular expressions.

If you think that a for loop is a good way to do this, how I can use it with the .Filter method, if possibile?
 

IoSonoPiero

Active Member
Licensed User
Longtime User
Sorry but I've not understood!

Actually I use table.Filter("colname LIKE '*CHARS*'")
where CHARS is the string users insert.

The function I want to implement is "simple".
I want to show all words that contains at least one capitalized chars. The chars can be one of the alphabet, I have not to specify this.

Can you repeat your question, please?
My english is not very good, today.
 

copiloto

Member
Licensed User
Longtime User
Hello,

I'd do it in this way:

first variable=table1.cell("column name",x)

if first variable<>strtolower(first variable) then
get it!!
end if

Perhaps is not the best or the faster solution, but it should work!!

Another posible solution is to create another table similar to this, but you must convert all the cells to strtolower(table1.cell("column name",x)).
Then you can easy comparate the same register of the two tables:

if table1.cell("column name",x)=table2.cell("column name",x) then ......

This last case is good if you plan to work very fast and intensive with this table...

Bye
 
Last edited:

IoSonoPiero

Active Member
Licensed User
Longtime User
Mmmhh, interesting.
But how you can use this code and show only data that has capitalized characters in it?
One solution can be to remove data that doesn't match, but I need all data, I have only to show (filter) a lot of rows and see only the rows that has capitalized text in that.

Thanks for the suggestion, however.
 

specci48

Well-Known Member
Licensed User
Longtime User
One solution can be to remove data that doesn't match, but I need all data, I have only to show (filter) a lot of rows and see only the rows that has capitalized text in that.
Have you already thought about a second table?

A possible workaround could be:
Store all your data in an "internal" (non visible) table. Now write a "filter"-routine on your own and fill the second (visible) table with all rows matching your search criteria. If no filter ist needed, just fill the visible table with all available rows of the invisible one.


specci48
 

IoSonoPiero

Active Member
Licensed User
Longtime User
Have you already thought about a second table?

A possible workaround could be:
Store all your data in an "internal" (non visible) table. Now write a "filter"-routine on your own and fill the second (visible) table with all rows matching your search criteria. If no filter ist needed, just fill the visible table with all available rows of the invisible one.


specci48
Yes, I'm working on a prototype using two tables, but at the end the solution is too heavy to implement.

I'm searching for something that uses minus "tricks".

So, eventually if I have to "associate" normal filtering with capitalized words, I can FIRST find capitalized words, the copy all this rows to the visible table, then use .Filter method on this table. Or not?

I'm implementing all this in the application you find here, to understand.

UPDATE:
When I filter the table, at the end I have to save on a file all data on the tabel, including hidden (filtered) values.

So, I think that it's impossible to achieve what I need.
 
Last edited:

IoSonoPiero

Active Member
Licensed User
Longtime User
This tiny code found a capitalized character in a string:

B4X:
Sub Globals
    'Declare the global variables here.
    Regex.New1("[A-Z]")
End Sub

Sub App_Start
    testString = "this iS a string"
    If Regex.IsMatch(testString) Then
        Msgbox("Found Capital Letter(s)!")
    End If
End Sub
There is a way to merge this with a .Filter method for a Table object?
 

IoSonoPiero

Active Member
Licensed User
Longtime User
In theory, if I create a hidden (width = 0) column called for example Capitalized, and then set it to 1 (true) or 0 (false) according to the Regex.IsMatch,
I can then use .Filter method like:
B4X:
table.Filter("colum1 LIKE 'something' AND Capitalized = 1")
???

In this way I think I can accomplish "normal" filtering + regex results.

Any comment?
 
Last edited:

IoSonoPiero

Active Member
Licensed User
Longtime User
Yes, it works very good!

I'm releasing an updated version of my application. :sign0060:
 
Top