Avatar of Ridgejp
RidgejpFlag for United Kingdom of Great Britain and Northern Ireland

asked on 

JQuery Search Filter

Hi,

I'm currently using a JQuery Search filter that up until now has performed brilliantly ... but I'd like to tweak it to handle 'character spaces' in the search terms.

The query looks like this currently: -

<script> 
    $(document).ready(function () {
		(function ($) 
		{
			$('#filter').keyup(function () {
            var rex = new RegExp($(this).val(), 'i');
            $('.searchable tr').hide();
            
            $('.searchable tr').filter(function () {
                return rex.test($(this).text());
            }).show();

            })

            }(jQuery));
    });
</script>

Open in new window


The search function fails if I search a record set returned into a bootstrap table using mysql as it will only find results where there is no character spacing. So if a product code is present in the returned record set such as "WHITE OVERSHOES" (by way of example) I would have to search for "WHITE"  or "OVERSHOES" as it would not be able to find "WHITE OVERSHOES" on account of the space.

How do I change this?

J
jQueryPHPAJAX

Avatar of undefined
Last Comment
Ridgejp
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Ridgejp
Ridgejp
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Works great ... thanks J.
PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo