Regex search problem/question
Regex search problem/question
I took the code for searching with regex (https://datatables.net/examples/api/regex.html) and put it on my server here
https://www.thrivezone.org/z2.php
I changed the table to demonstrate my problem by changing some names to 'alum' and 'balum'
To find only records with alum (and not balum), I would usually use this expression
[^b]alum
But this returns nothing. If my regex expression is correct, why isn't it returning anything?
Thanks
This question has an accepted answers - jump to answer
Answers
I tried your test page and it returns a search result. Whether I use the global or name column and enable regex searching for
[^b]alum
returns rows with bothalum
andbalum
. If I change the search to^[^b]alum
then only rows withalum
are displayed.Kevin
Thanks Kevin...not sure why it works this way, but it does work.
In what way are you referring?
Kevin
why you need two ^ when you only need to eliminate one character...that's what I don't understand..anyway, thanks
You are right. Both of us had the wrong regex. Your regex needs to be more like this:
\b(?!b)\w*alum\b
With this you will get
alum
, 'calum(or any character(s) before alum except
b. The
\b` is a word boundary.With this
[^b]alum
there needs to be one character (but notb
) beforealum
to match. Which is whyalum
did not produce any results.Kevin
perfect...that works...thanks so much