DataTables and Regex search

DataTables and Regex search

jmeilejmeile Posts: 28Questions: 4Answers: 0

Dear all

I'm looking at the example:

I know how to look columns containing the search terms "Tokyo" or "London". I just have to input: "Tokyo|London" in the "Global search" field, then check: "Treat as regex". How can you look for rows containing: "Software" and "London"?

This should return this two rows:

Bradley Greer       Software Engineer   London  41  2012/10/13  $132,000
Bruno Nash          Software Engineer   London  38  2011/05/03  $163,500

Is this possible? What do I have to type in the "Global search" field?

Best regards


  • jmeilejmeile Posts: 28Questions: 4Answers: 0
    edited November 2021

    I think I found it:


    This seems to work. Is that the correct way?

    My idea is offering the user a search input to enter keywords separated by semicolons.Right after, he will have two radio buttons: "Match any" and "Match all".

    In order to avoid real time processing, I will catch the "keydown" handler and wait until the user hits the ENTER key. Then I will split that string into an array of search terms and then join them with the or operator '|' or by using the previous regex.

    Now, I'm facing another problem. If I want to match a phrase, for example: "Software Engineer" and "London", this regex won't work:

    (?=.*\bsoftware engineer\b)(?=.*\blondon\b)

    How should be this formatted?

  • jmeilejmeile Posts: 28Questions: 4Answers: 0
    edited November 2021

    Sorry, it is actually working. I think I make a typo. By the way, I just noticed that the \b modifier only matches if it is next to a word delimiter, for example: an space or a tab. But I want to match everything, so, I replaced it by:

    (?=.*oftware enginee.*)(?=.*ondo.*)

    So that, It will match the rows I want.

  • jmeilejmeile Posts: 28Questions: 4Answers: 0

    Just for the records: the example I linked before is the wrong one. I was using this one:

    which actually has regex support.

Sign In or Register to comment.