Skip to main content
Inspiring
August 16, 2020
Answered

How to apply RegExp to search for some string using ExtendScript

  • August 16, 2020
  • 1 reply
  • 498 views

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. 

 

This topic has been closed for replies.
Correct answer Manan Joshi

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

1 reply

Manan JoshiCommunity ExpertCorrect answer
Community Expert
August 16, 2020

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

-Manan
Inspiring
August 16, 2020

It worked!

Yes the substitution is the issue!

THANK YOU SO MUCH! and sorry for my lack of declartion i was in rush.