Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to apply RegExp to search for some string using ExtendScript

Participant ,
Aug 16, 2020 Aug 16, 2020

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. 

 

TOPICS
Activation billing and install , Bug , EPUB , Feature request , How to , Import and export , InCopy workflow , Performance , Print , Publish online , Scripting , SDK , Sync and storage , Type
452
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 16, 2020 Aug 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

Translate
Community Expert ,
Aug 16, 2020 Aug 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 16, 2020 Aug 16, 2020
LATEST

It worked!

Yes the substitution is the issue!

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

 

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