{"id":331,"date":"2010-09-13T11:29:15","date_gmt":"2010-09-13T01:29:15","guid":{"rendered":"http:\/\/threemillion.net\/blog\/?p=331"},"modified":"2018-07-31T12:57:09","modified_gmt":"2018-07-31T02:57:09","slug":"indexof-is-case-sensitive","status":"publish","type":"post","link":"https:\/\/threemillion.net\/blog\/?p=331","title":{"rendered":"IndexOf is Case Sensitive"},"content":{"rendered":"<p>Whilst doing some string manipulation recently was having issues getting the correct data, or rather the data I expected. Consider the following:<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nPS ...Scripts&gt;$SQLCmd = &quot;SELECT Name, Vendor From esx_config WHERE Name=&#039;myesx1&#039;&quot;\r\nPS ...Scripts&gt;$Position = $SQLCmd.IndexOf(&quot; FROM &quot;)\r\nPS ...Scripts&gt;$Position\r\n-1\r\n<\/pre>\n<p>The result is a -1, which is not correct, however does make sense when looking for correct case.<\/p>\n<p>After some hunting around and numerous search result was able to sort my issue and made the following adjustment.<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nPS ...Scripts&gt;$SQLCmd = &quot;SELECT Name, Vendor FrOm esx_config WHERE Name=&#039;myesx1&#039;&quot;\r\nPS ...Scripts&gt;$Position = $SQLCmd.IndexOf(&quot; FROM &quot;, [StringComparison]&quot;CurrentCultureIgnoreCase&quot;)\r\nPS ...Scripts&gt;$Position\r\n19\r\n<\/pre>\n<p>Now I get the correct position.<\/p>\n<p>Only tested on Powershell v2.0.<\/p>\n<p><strong>Note<\/strong>: The\u00a0overload\u00a0does not work on an Array. \ud83d\ude41<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Whilst doing some string manipulation recently was having issues getting the correct data, or rather the data I expected. Consider the following: The result is a -1, which is not <a href=\"https:\/\/threemillion.net\/blog\/?p=331\" class=\"more-link\">[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[8,5],"tags":[],"class_list":["entry","author-admin","post-331","post","type-post","status-publish","format-standard","category-powershell","category-scripting"],"_links":{"self":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/331","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=331"}],"version-history":[{"count":7,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/331\/revisions"}],"predecessor-version":[{"id":791,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/331\/revisions\/791"}],"wp:attachment":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=331"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=331"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}