Luke 18 Posted June 24, 2010 Report Share Posted June 24, 2010 More of a tutorial than a trick or tip, I thought I'd post what I've learned about the ever-confusing $replace function here for others to find... You have to think of replace as having FOUR inputs, not just the three you see when you open it. The fourth is found just before you open the replace window, the actual thing you are replacing. Sometimes you need it to be the same as the first setting (original) and sometimes it shouldn't be... Depending on your needs at the time. If you're modifying your source information itself during the replacement, then it will be the exact same as your 'Original' value, in the first field. If you want to replace a source with something totally unrelated, say, the openeing words from the declaration of independence, then your source would be a totally different variable from your 'Original' variable. The "search" and "replace" are just modifying the "original" value, not the source value. So to sum it up, the: 1. Source is usually a variable that exists where you want the new thing to be. 2. Original is either that same variable or another if you want to pull in some other content entirely, 3. Search is the specific text/code you're looking to replace inside 'original', and 4. Replace is just what you want to go there... Usually a variable or the $nothing function, in the case you just want to delete all instances of something. Hope that helps!Luke 1 Quote Link to post Share on other sites
UBotBuddy 331 Posted March 13, 2011 Report Share Posted March 13, 2011 Nice share Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.