What function might I use to find a character position in a string using PowerShell 2.0.
i.e I would use CHARINDEX or PATINDEX if using SQL Server.
I looke
The string is a .NET string so you can use .NET methods. In your case:
$index = "The string".IndexOf(" ")
will return 3, which is the first occurrence of space in the string. For more information see: http://msdn.microsoft.com/en-us/library/system.string.aspx
For your need try something like:
$s.SubString($s.IndexOf("_") + 1, $s.LastIndexOf(".") - $s.IndexOf("_") - 1)
Or you could use regexps:
if ($s -Match '(_)(.*)(\.)[^.]*$') { $matches[2] }
(has to be adjusted depending on exactly what you need).