How to check if title contains character

how could i check for all titles that contains 3 characters that the user types in

var query = $(“#subSiteTitle”).val();

The value that the user types in must be length >2
So if the user types for ex Sub, i want to filter items that first contains S and then u and then B
My query right now only display if just that string contains in a title
So if i type Sub in my query val, and if i have 2 title with title “ASub” and “HelloSub”
My query in the bottom will display that, but if i also have a title named “Bus” that wont display when searching for “Sub”, how could i make so when typing for example “Sub” display “Asub”, “HelloSub” and “Bus” also because the entered keyword “Sub” contains S,u,b but its not displaying Bus also? why?

var queryUrl = appweburl + “/_api/SP.AppContextSite(@target)/web/webs?$select=Title,Url,WebTemplate&$filter=WebTemplate ne ‘APP’ and substringof(‘” + query + “‘, Title)&@target='” + hostweburl + “‘”;

enter code here



1 Answer


The string ‘Bus’does not contain the string ‘Sub’, so the filter for substringof should not return this in the result.

If you need to return items that contains all the characters in any place in the title, you should split the query text (like ‘sub’) to characters (‘s’, ‘u’ and ‘b’) and filter the items by logical ORing the substringof expressions in the $filter.

I have to say I find this kind of requirement rather strange. What is you goal?
It might be more efficient (depend on the number of your webs), to get the all the webs from the server via REST and then filter them on the client side in JavaScript.