And Operator in Custom filter for search api is not working

And Operator in Custom filter for search api is not working

tp007tp007 Posts: 2Questions: 1Answers: 0

I want to filter records based on Text value using search api. e.g. below I want to filter records which ends with 11 But it should not include chl-ccsp-011 . I have tried below query but it is not working. Please suggest me how can i achieve ?.

filterText = "((11$)) && ((^(.(?!chl-ccsp-011))*$))";

$("#" + tableId).DataTable().column(colNum).search(filterText, true, false);

Thanks,
Tushar Prajapati

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    With regexes, you also need to define what it should include, as well as what it shouldn't. For example, would "chl-011" be matched, or "11", or "011"?

    Colin

  • tp007tp007 Posts: 2Questions: 1Answers: 0

    I have already set regrex to true in filters. Am i missing anything? I am not getting it.

  • kthorngrenkthorngren Posts: 21,327Questions: 26Answers: 4,949
    edited June 2021

    You need to build the proper regex expression. Regex is going to try a literal match of &&. Checkout this SO thread about not operators. I would first use a site like https://regex101.com/ to build the regex expression. Once it works there try it with Datatables.

    Another option is to create a search plugin. See this example.

    Kevin

Sign In or Register to comment.