To add more precision to floating point numbers, I have to go through a bunch of C# classes and, wherever there is a division operation, multiply both the numerator and denominator by 1000. So suppose we have a numerator, n and a denominator, d. Then the original would look like this: n / d. And I would need to change it to (n*1000)/(d*1000).
To search for all the division operators I'm using the find function (ctrl+f) in Visual Studio 2013 Ultimate. I'm searching for all '/'. The problem is that the find function also picks up the slashes in the comments. How can have the find function only find the single slash '/' and not the double slash '//'?
Thank you for any suggestions.
Regex find (Ctrl+Shift+F with the Use Regular Expressions option checked) [^/<]/[^/>]
in your solution - basically a /
that:
/
or a <
(i.e. closing XML comment tags like </para>
)/
or a >
(i.e. standalone XML comment tags like <see cref="Foo"/>
)The only false positives I see with this approach in a quick check against a solution of ~80 projects are...
1/1/2014
)/
in comments (e.g. Note that an up/down change....
)...but others could come up depending on your code base - for example:
http://stackoverflow.com/users/1810429/j0e3gan
)/Customer/Address/City/text()
)If you consistently put spaces between the division operator and its operands, you could tighten the regex a bit to alleviate these false positives, changing it from...
[^/<]/[^/>]
...to...
[^/<] +/ +[^/>]
...where +
will match one or more spaces of course.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With