You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
String.indexOf() is being used for phrase search. There are two scenarios where this will fail because of whitespace:
Justified text, very common in legal documents, which can result in variable amount of whitespace between words.
Currently spaces are not added between lines therefore phrases that span multiple lines will not be found. See Improve Copy/Paste #5783 for more information.
Even if 2 is fixed, we still have to deal with 1 for phrase search. I have written a JS function that is equivalent to String.indexOf() but ignores " " while matching. This function also returns the end index since the length of searchValue cannot be trusted because the amount of whitespace between text and searchValue may differ. It could be modified to handle all whitespace characters, but I think it is unnecessary in this case since the text layer converts all whitespace to " ".
functionindexOfIgnoreSpace(text,searchValue,fromIndex){varbegin=0;varend=-1;varfragment=searchValue.slice(0).split(' ').join('');// remove whitespaceif(!fromIndex){fromIndex=0;}for(vari=fromIndex;i<text.length;i++){// do not start matching on whitespaceif(text[i]===' '){continue;}varindex=0;begin=i;for(varj=i;j<text.length;j++){if(text[j]===' '){continue;}if(text[j]!==fragment[index]){break;}index++;if(index===fragment.length){end=j+1;break;}}if(end!==-1){return{begin: begin,end: end};}}returnnull;}
The text was updated successfully, but these errors were encountered:
String.indexOf()
is being used for phrase search. There are two scenarios where this will fail because of whitespace:Even if 2 is fixed, we still have to deal with 1 for phrase search. I have written a JS function that is equivalent to
String.indexOf()
but ignores" "
while matching. This function also returns the end index since the length ofsearchValue
cannot be trusted because the amount of whitespace betweentext
andsearchValue
may differ. It could be modified to handle all whitespace characters, but I think it is unnecessary in this case since the text layer converts all whitespace to" "
.The text was updated successfully, but these errors were encountered: