I have a block of code that looks like this (it's from a XIB file)
<tabBar contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ZTF-8n-Y8A">
<rect key="frame" x="2" y="431" width="320" height="49"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<items>
<tabBarItem title="Item" id="vcz-nP-1al"/>
<tabBarItem title="Item" id="9mv-O2-GXB"/>
</items>
</tabBar>
I have found the first line of the block by searching for the id using the following
foreach(var search in Outlets.Values)
{
var ui = new UIObject();
var fullSearch = string.Format("id=\"{0}\"", search);
using (var reader = File.OpenText(infile))
{
var line = await reader.ReadLineAsync();
if (line.Contains(fullSearch))
where Outlets is a Dictionary
I can grab the entire in the file being read in and store that in a string or more likely, a string builder object.
What I'm trying to do is search for key parts of the block - for example, width="320". I need to separate width="320" from the rest of the string and then remove the 320 part.
I did consider using IndexOf("width") and then count 6 along to get to the inside of the quotes up to the next quote mark, but that's probably fairly inefficient - especially if the string is long.
Is there a way to take a section of a string in the way I describe?