Copy link to clipboard
Copied
Hello,
I hope you all are doing well.
I have a small probelm, i want to compare a string with a URL but since thier is a spaces in the url, the url looks like this (hey%20blabla%20opopop%20ssasa%20somedata%20test). I've tried to combined 2 strings (blabla test) to look for it and to seprate strings but still when i use below functions it dosen't work, the extendscript dont recognize it, due the precentage.
combaind string
if ( url.indexOf(CombaindStr) >= 0){
}
seprate strings
if (url.toString().indexOf(str1) >= 0 && url.toString().indexOf(str2) >= 0 ){
I thought about RegExp but i didn't know how to apply it, ant one can help with it?
I'm using JS
Thanks all.
I did not understand your question fully, but if the substitution of space character is the issue with your comparison, you can use the decodeURI method. It will convert the %20 and other such characters, back into there decoded form. For an example see the following code snippet
var url = "hey%20blabla%20opopop%20ssasa%20somedata%20test"
var compareString = "hey blabla opopop ssasa somedata test"
alert(compareString == decodeURI(url))
-Manan
Copy link to clipboard
Copied
I did not understand your question fully, but if the substitution of space character is the issue with your comparison, you can use the decodeURI method. It will convert the %20 and other such characters, back into there decoded form. For an example see the following code snippet
var url = "hey%20blabla%20opopop%20ssasa%20somedata%20test"
var compareString = "hey blabla opopop ssasa somedata test"
alert(compareString == decodeURI(url))
-Manan
Copy link to clipboard
Copied
It worked!
Yes the substitution is the issue!
THANK YOU SO MUCH! and sorry for my lack of declartion i was in rush.