"Search with pattern" problem
I'm working on a VB project. My current objective is to find all occurences in code which may cause problems with localization, because there is a new requirement fpr supporting multiple languages and locales. I have identified occurences of date conversions with string constants like this:
myDateVar = CDate("01.10.1999")
I have tried to use "Search with pattern" to find all occurences of this kind. Therefore i defined the following pattern:
CDate($arg1$)
where arg1 is defined as expression of System.String. When i execute the pattern R# puts also all CInt, CStr... occcurences in the find result even is i uncheck "Match similar constructs". Do i miss something or is the function buggy?
By the way, my goal is to replace all occurences by using a Date like this
myDateVar = new Date(1999, 10, 1)
Is this possible with structural find and replace?
Regards
Klaus
Please sign in to leave a comment.
You should be able to do this with Visual Studio's built-in Find & Replace.
This assumes that the string passed to CDate always uses "." as the date separator, and is always specified in D/M/Y format.
There's a reference for the perculiar Regex syntax that Visual Studio uses on MSDN:
http://msdn.microsoft.com/en-us/library/2k3te2cs(v=vs.100).aspx
Hi Richard,
thanks for the hint. Your solution works perfect. I should pay more attention to the power of regular expressions in the future :).
Regards
Klaus