Main
|
Resume
|
Showreel
|
Blog
|
Script
|
Contact
connexion
go to footer
expand all
|
collapse all
languages
class
All
JScript|XSI
Python|XSI
JScript|WEB
Python|Maya
All
Memo
learning
DDD
php
tool
keyboard tooltips
rig
SearchAndReplace( inString, inSearch, inReplace, inCase )
- All - felixlecha
// Search and replace (use Condition Case) // INPUT : // inString (string) // inSearch (string) // inReplace (string) // inCase (boolean) // OUTPUT : // inString (string) function SearchAndReplace( inString, inSearch, inReplace, inCase ) { if(inCase){ var oReg = new RegExp(inSearch, "g"); } else{ var oReg = new RegExp(inSearch, "gi"); } var inString = inString.replace(oReg, inReplace); return inString; } // Test : // LogMessage( SearchAndReplace("felix likes chocolate, he eat Chocolate everyday.", "chocolate", "Code", 0 )); // LogMessage( SearchAndReplace("felix likes chocolate, he eat Chocolate everyday.", "chocolate", "Code", 1 ));