RegEx
In the past I've always used regular expressions purely to validate text input, but did you know you can extract and replace text with RegEx too?
I recently ran into an issue where i needed to replace the following text
BusinessObjects.YesNoQuestion("Are You Sure?", True)
With
MsgBox("Are You Sure?", YesNo)
The tricky part was that I had to do this X number of times and that the message was different for each instance. No problem for regex. Just "tag" the message and backreference it resulting in the following Find/Replace string.
Find: (BusinessObjects\.)@YesNoQuestion\({\"@.+\"@}\, True\)
Replace: MsgBox(\1\, MsgBoxStyle.YesNo)
The curly brackets mark the string to be used later and the \1 used in the replace string iswhere the first tagged will be inserted.
Nice.
January 1st, 2009 - 21:27
The letter service uses RegEx for token-content replacement, worked out nice too.