Skip to main content
Inspiring
Dec 4, 2015 4:22 AM UTC
Question

Searching multiple words in a string

Hi,

I've got this code in my AS3 :

var str:String = mySharedObject.data.theDate;

var search:String = "monday";

var replace:String = ""; 

function strReplace(str:String, search:String, replace:String😞String {

return str.split(search).join(replace);

}

Is it possible to tell the code to search for "monday or tuesday or wednsday, or thursday, or friday" and replace them with "_" ?

I would like to something like


var search:String ="tuesday","wednsday","thursday";

But it's not working..

This topic is closed to new replies. Start a new post to keep the conversation going.

2 replies

Amrita Gangwani
Adobe Employee
Adobe Employee
Dec 4, 2015 5:37 AM UTC

you can try doing that using arrays and passing values through loop, referencing different indexes.

Translate
Colin Holgate
Inspiring
Dec 4, 2015 4:33 AM UTC

You don't show how you call the function, and your example was to replace with "_", but your code is using "".

Translate