Highlighted

How to apply RegExp to search for some string using ExtendScript

Participant ,
Aug 16, 2020

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. 

 

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

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

Topics

Activation billing and install, Bug, EPUB, Feature request, How to, Import and export, InCopy workflow, Performance, Print, Publish online, Scripting, SDK, Server developers, Sync and storage, Type

Views

52

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

How to apply RegExp to search for some string using ExtendScript

Participant ,
Aug 16, 2020

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. 

 

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

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

Topics

Activation billing and install, Bug, EPUB, Feature request, How to, Import and export, InCopy workflow, Performance, Print, Publish online, Scripting, SDK, Server developers, Sync and storage, Type

Views

53

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 16, 2020 0
Adobe Community Professional ,
Aug 16, 2020

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 16, 2020 0
Participant ,
Aug 16, 2020

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.

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 16, 2020 0