Highlighted

Searching multiple words in a string

Contributor ,
Dec 03, 2015

Copy link to clipboard

Copied

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..

TOPICS
Development

Views

124

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

Searching multiple words in a string

Contributor ,
Dec 03, 2015

Copy link to clipboard

Copied

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..

TOPICS
Development

Views

125

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
Dec 03, 2015 0
Adobe Community Professional ,
Dec 03, 2015

Copy link to clipboard

Copied

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

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...
Dec 03, 2015 0
Adobe Employee ,
Dec 03, 2015

Copy link to clipboard

Copied

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

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...
Dec 03, 2015 0