This Question is Answered

1 "correct" answer available (4 pts) 1 "helpful" answer available (2 pts)
2 Replies Last post: Apr 26, 2012 9:01 AM by Klaus Luedenscheidt  
Klaus Luedenscheidt Apprentice 737 posts since
May 28, 2004
Currently Being Moderated

Apr 25, 2012 5:21 PM

"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:




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?




Richard Deeming Novice 193 posts since
Oct 6, 2010
Currently Being Moderated
Apr 25, 2012 10:46 PM in response to: Klaus Luedenscheidt
Re: "Search with pattern" problem

You should be able to do this with Visual Studio's built-in Find & Replace.


  1. Ctrl+Shift+H or Edit -> Find and Replace -> Replace in Files;
  2. In the "Find what" box, enter: CDate\("{:z}\.{:z}\.{:z}"\)
  3. In the "Replace with" box, enter: new Date(\3, \2, \1)
  4. Click on the "+" next to "Find options", tick the "Use" box, and make sure the drop-down list is set to "Regular Expressions";


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:

More Like This

  • Retrieving data ...