Using Smart and Regex and searching

Using Smart and Regex and searching

barrykeepencebarrykeepence Posts: 22Questions: 0Answers: 0
edited July 2013 in Feature requests
I wanted to search with regex and look for multiple matching elements so I turned on smart search.
The problem with smart search is that it splits strings on spaces so if I wanted to search for a string with spaces it would split it.

I changed the function to this:
[code]
function _fnFilterCreateSearch( sSearch, bRegex, bSmart, bCaseInsensitive )
{
var asSearch, sRegExpString;

if ( bSmart )
{
/* Generate the regular expression to use. Something along the lines of:
* ^(?=.*?\bone\b)(?=.*?\btwo\b)(?=.*?\bthree\b).*$
*/
asSearch = bRegex ? sSearch.match( /\w+|"[^"]+"/g ) : _fnEscapeRegex( sSearch ).split( ' ' );
if ( asSearch ) {
for (var i=0;i

Replies

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    The problem with having both smart filtering enabled and entering custom regex is that they can conflict quite badly, resulting if unexcited bugs. This is because one regex is being put inside another and of course they might interact. That is why I've got them separate.

    Having said tat, if this is a feature required often enough (this is the first request) I will look at adding that ability.

    Regards,
    Allan
  • barrykeepencebarrykeepence Posts: 22Questions: 0Answers: 0
    I wouldn't say this is custom regex.
    My users can understand simple regex but not advanced regex. I was using the non-regex and smart filtering for my users and they complained about not being able to enter search strings (e.g. in quotes).
    The problem with smart filtering is that it will always split on a space even if it is in quotes.
    How about just changing smart filtering to not split on spaces in between quotes?
  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    edited July 2013
    "Custom regex" in the sense that it has regular expression characters in it at all. .* can do funny things with the smart filtering for example.

    > The problem with smart filtering is that it will always split on a space even if it is in quotes

    In needs to do that split in order to do the smart filtering (i.e. individual word, regardless of its position in the string).

    Changing it to not split between quotes sounds like a decent idea, although currently it searches for the quotes as well, so it would be a change in behaviour. Possibly a good one though - that's an ability I use in Google quite a lot myself.

    Allan
  • barrykeepencebarrykeepence Posts: 22Questions: 0Answers: 0
    Sounds like a yes?
  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    Yes, but probably not in the immediate future. Possibly not even for 1.10 - although I will have a think about how to best do it.

    Good feature suggestion :-)

    Allan
This discussion has been closed.