Closed matrs closed 2 years ago
Hi @matrs , well I am afraid it is going to be difficult to port either
regex
apisearch
](https://datatables.net/reference/api/search()) apias they both involve additional HTML fields (i.e. the search filter is not taken from the search box of the table), and also require additional javascript that at the moment we can't really fit that into our table template.
I think what you are looking for is more something like the search.regex
option. You can pass it to your datatable like this:
show(df, search={"regex": True})
or
import itables.options as opt
opt.search={"regex": True}
This option does has some impact, cf. the search for *
which returns the original table on the second cell (and no result when search.regex=False
):
However I must say that I have not been able to search for specific end of words so maybe the exact way to use it is a bit more complex. Maybe you'll have to deactivate the search.smart
parameter, e.g.
show(df, search={"regex": True, "smart": False})
All the possible search options are listed here. Please keep us posted and let us know what works for you! I'll be happy to update the README when we have an example that works well.
Hi @mwouts , thank you for your prompt answer. The option search={"regex": True}
is what I was looking for and until now it has worked as expected (I was specially interested in |
).
About the "end of word" pattern, without disabling the smart search, it works: wound\b
returns only wound, but wound
returns wounding
too. Maybe you are referring to something else?
Oh great! I'll add the example to the README, then.
About the "end of word" pattern, without disabling the smart search, it works: wound\b returns only wound, but wound returns wounding too. Maybe you are referring to something else?
Yes, I wanted to use the ^
or $
boundaries, but my attempts were unsuccessful (all I got was an empty table when I was expecting a match). Let me know if they work for you!
I see. With $
and ^
I'm getting the same result as you, empty tables.
Hello, thanks for this library, it's been really useful.
I'm looking to use regular expressions as input for the search box. There is an example here, where you mark the regex box and the search box works as expected. Is it possible to add that function to my code? I really don't know how to go about it and any help/example is appreciated (I dont'care for the option boxes, if the default search box understand regular expressions would be more than enough).
Also, in the documentation about the [API
search()
](https://datatables.net/reference/api/search()), says:Where one of the parameters is: