 




<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The VBScript Network and Systems Administrator&#039;s Cafe &#187; InStr function</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/tag/instr-function/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator</link>
	<description></description>
	<lastBuildDate>Tue, 11 Oct 2011 18:36:53 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Easy String Searches with the VBScript Instr function</title>
		<link>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/easy-string-searches-with-the-vbscript-instr-function/</link>
		<comments>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/easy-string-searches-with-the-vbscript-instr-function/#comments</comments>
		<pubDate>Fri, 30 Jan 2009 01:30:43 +0000</pubDate>
		<dc:creator>Jerry Lees</dc:creator>
				<category><![CDATA[InStr function]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[String manipulation]]></category>
		<category><![CDATA[strings]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/?p=104</guid>
		<description><![CDATA[I recently had a situation where I needed to find string inside a string to parse the larger string into usable and separateÂ chunks of data. In writing this script, I realized I&#8217;ve not shared this gem of a function with you previously&#8230; and it really makes matters easier when you are manipulating strings. That [...]]]></description>
				<content:encoded><![CDATA[<p>I recently had a situation where I needed to find string inside a string to parse the larger string into usable and separateÂ chunks of data. In writing this script, I realized I&#8217;ve not shared this gem of a function with you previously&#8230; and it really makes matters easier when you are manipulating strings.</p>
<p>That function is the Instr function. When configured with the proper parameters, by default, it will return the FIRST location in a string where a sub-string occurs. (Hint: this is where a mid() function would come in handy after you have that starting location). If the sub-string is not found, the function returns 0. The syntax is as follows:</p>
<blockquote><p><strong>Instr(StartPostion, StringToSearch,StringtoFind, Compare)</strong></p></blockquote>
<p> </p>
<p>Â The script I wrote really is a blog entry of it&#8217;s own, and will be, but I wanted to first introduce you to this great function and let you have a chance to play with it and see some code in action. Below is an example script that takes a string and searched for specific sub strings, then returns the location in the string where the sub string occurs.</p>
<p> </p>
<p><span>Option explicit<br />
Dim StrSource</span></p>
<p><span>StrSource = &#8220;Now I can find a word In a long string of words in a sentance.&#8221;</span></p>
<p><span>WScript.Echo(InStr(1,StrSource,&#8221;In&#8221;))<br />
WScript.Echo(InStr(1,StrSource,&#8221;in&#8221;))<br />
WScript.Echo(InStr(1,StrSource,&#8221; in &#8220;))<br />
WScript.Echo(InStr(1,StrSource,&#8221;now&#8221;))</span></p>
<p>Below is the output from the script. Notice, the following:</p>
<ul>
<li>The case of <strong><span>in</span></strong> and <span><strong>In</strong></span> in the sub-string being searched for and the positions it returns?</li>
<li>Notice the substring &#8220;<span><strong>in</strong></span> &#8221; returns something entirely different?</li>
<li>Notice the substring <strong><span>now</span></strong> returns 0?</li>
</ul>
<p> </p>
<p>23<br />
12<br />
48<br />
0</p>
<p> </p>
<p>Enjoy!</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/easy-string-searches-with-the-vbscript-instr-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
