Negative filters (ie. how do you search for cells that do not match a string)

Negative filters (ie. how do you search for cells that do not match a string)

shamufishshamufish Posts: 14Questions: 0Answers: 0
edited October 2010 in General
Hello!

So basically I'm trying to search for rows that do not contain a certain piece of string.

For example, say I have a column that contains the following unique values : firefox, internet_explorer, safari. How do I show *only* the rows that are not containing 'safari' (ie, the rows that include firefox OR Internet_explorer).

I tried various negative lookup regexp to no avail...

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    You can use the fnFilter API function with regex to do a negative filter: http://www.datatables.net/api#fnFilter . Note that DataTables puts in smart filtering which a regex expression - you might want to disable that (again with the API function) while working on your regex so it doesn't get in the way (it would almost certainly do in a look behind).

    Allan
  • shamufishshamufish Posts: 14Questions: 0Answers: 0
    edited October 2010
    Thank you Allan, I'll complete my own post by saying the following expression will not select anything containing 'Completed':

    [code]fnFilter('^(?:(?!Completed).)*$'[/code]
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Nice one - thanks for the feedback :-)

    Regards,
    Allan
This discussion has been closed.