Remove white space inside single quotes before and after text inside the quotes

I am using a third-party plugin for javascript called QueryBuilder.

The problem is there is no way to trim the input after saved so the data is being saved like

testName='   test   '

this is my javascript code, which is removing all spaces which is not what I want, I am trying to remove just space in the single quotes before and after all the text. Pretty much like a trim but the trim is not working so I need a regex to replace method

get_condition_sql__str = $.trim(get_condition_sql.sql);
                get_condition_sql__clean = get_condition_sql__str.replace(/\s/g, '')
                console.log(get_condition_sql__clean);
                jQuery('.exception_conditions__sql').val(get_condition_sql__clean);

45 thoughts on “Remove white space inside single quotes before and after text inside the quotes”

Leave a Comment