searching datatable with multiple values not returning exact match

searching datatable with multiple values not returning exact match

inquisitive_sthainquisitive_stha Posts: 7Questions: 6Answers: 0

https://jsfiddle.net/z5390fqs/

On Unit Column:
Uncheck all Option
Check option 1 and 2

This should have returned only those rows with unit value 1 or 2 but it is returning other numbers like 10 and 103 as well.

I am using selectedArr.join('|') to search for multiple values.

Answers

  • kthorngrenkthorngren Posts: 21,173Questions: 26Answers: 4,923

    An easy way to validate your regex expressions is to use https://regex101.com/ . I placed your regex and data in this example:
    https://regex101.com/r/452rsg/1

    The right side describes how the regex will work:

    1st Alternative ^1
    ^ asserts position at start of a line
    1 matches the character 1 literally (case sensitive)
    2nd Alternative 2$
    2 matches the character 2 literally (case sensitive)
    $ asserts position at the end of a line

    Maybe a non-capturing group will work, for example: ^(?:1|2)$.

    Kevin

This discussion has been closed.