473,320 Members | 2,080 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

IndexOf and LastIndexOf not working

Using StreamReader to open and read files, I'm trying to parse some
text within a file at a starting point grabbing all the text to the
ending point; it works on one particular file (a .txt file)
with no problem, but on an .asp file when I try it

abc1 = xyz1.Substring(xyz1.IndexOf("starting keyword"),
xyz1.LastIndexOf("ending keyword"))
Response.Write(abc1)

it goes beyond the LastIndexOf keyword and grabs a bunch of following
text (about the next 4r or 5 lines)... my ending keyword only shows up
once in the particular file I'm trying to parse, so I know I'm not
doing anything wrong there.
????
NetSports

Jan 18 '06 #1
2 1464
I'd start by doing something like this to see if you're getting what
you're exepcting from the search functions:

response.write(string.format("Starting Keyword
Postion:{0}<br>",xyz1.IndexOf("starting keyword")))

response.write(string.format("Ending Keyword
Postion:{0}<br>",xyz1.LastIndexOf("Ending keyword")))

Then see what it's finding at the ending keyword position.

Jan 18 '06 #2
Thanks for the insight , and how to use the Position method here, but I
need to find out with the code I posted why I'm getting text beyond my
Ending Keyword here when I need it to stop at the Ending Keyword

..netsports

Jan 18 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: ValyaS | last post by:
I have a byte array (myArray) filled by reading bytes from the Com port. And I need to check for a termination byte (0x00 or "\0") as well as for a combination of bytes/ASCII characters...
1
by: Matt | last post by:
In test() method: var path="C:\test\hello.txt"; //returns -1 for path.lastIndexOf("\\"). why?? var pos=path.lastIndexOf("\\"); //return -1 But in showFile() method: We are able to get the...
9
by: sklett | last post by:
string url = http://localhost/subPath/Default.aspx; k = url.LastIndexOf("/", 0, url.Length); This throws an exception: Count must be positive and count must refer to a location within the...
1
by: Richard L Rosenheim | last post by:
I'm having a problem with IndexOf on a large string. The string contains an ASCII file which is about 45K. IndexOf is not finding substrings that I know are in the string. Yes, I double-checked...
11
by: Al | last post by:
This statement returns a -1, indicating "not found": Find1 = Array.IndexOf(FilesArray, "sa001") But IndexOf on a specific item in that array returns a value of 26: Find1 =...
3
by: Terry Olsen | last post by:
I have a string that is approximately 600 characters. I need to divide up the string into 400 character chunks. I'm having trouble with using LastIndexOf. The following code returns a value of...
1
Atli
by: Atli | last post by:
The following small HowTo is a compilation of an original problem in getting some cookie-values through different methods of string-handling. The original Problem was posted as follows: As...
9
by: senfo | last post by:
I realize it's Friday and I'm probably already on vacation for the remainder of the day; but, I have a really, really stupid question. Is there a bug in the .NET 2.0 Framework in regards to the...
1
by: mad.scientist.jr | last post by:
I am working in C# ASP.NET framework 1.1 and for some reason Regex.Split isn't working as expected. When trying to split a string, Split is returning an array with the entire string in element ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.