Comments

: Hi guys,: : Basically I am indexing through lines of text in a text file.: : I am looking to delete lines of text with a singular W in it with a space at either side. ie " W ": : I would delete this line if I could find it:-: : The cat sat on the W mat.: : The lines of text are read in as AnsiStrings: : AnsiString LineToCheck;: : if (LineToCheck.AnsiPos(" W ")>0): {: Blah Blah Blah: }: : // this should find the above line but is doesn't. Any idea how I can overcome this ??: : Thanks: Graham: [blue]Can you use strstr() to check for a substring in LineToCheck?

: : Hi guys,: : : : Basically I am indexing through lines of text in a text file.: : : : I am looking to delete lines of text with a singular W in it with a space at either side. ie " W ": : : : I would delete this line if I could find it:-: : : : The cat sat on the W mat.: : : : The lines of text are read in as AnsiStrings: : : : AnsiString LineToCheck;: : : : if (LineToCheck.AnsiPos(" W ")>0): : {: : Blah Blah Blah: : }: : : : // this should find the above line but is doesn't. Any idea how I can overcome this ??: : : : Thanks: : Graham: : : [blue]: Can you use strstr() to check for a substring in LineToCheck?: : Take Care,: Ed[/blue]: : Hi Ed, It would appear not. I think strstr() is for character strings and at this stage I cannot convert my ansistring LineToCheck into a character string to do the check. I can't understand why AnsiPos or Pos won't find the " W " correctly.

: Hi Ed, It would appear not. I think strstr() is for character strings and at this stage I cannot convert my ansistring LineToCheck into a character string to do the check. I can't understand why AnsiPos or Pos won't find the " W " correctly.: : Graham: [blue]Is it possible the case of the W or the spaces are being read oddly? Have you tried seaching for other substrings? You've probably tried these methods, but I'm trying to help from afar. How about looking for the hex values of the spaces - x20Wx20, as referenced in the first link below. I know you've probably also scoured the web, but here are some Borland pages, if they may help:

: : Hi Ed, It would appear not. I think strstr() is for character strings and at this stage I cannot convert my ansistring LineToCheck into a character string to do the check. I can't understand why AnsiPos or Pos won't find the " W " correctly.: : : : Graham: : : [blue]: Is it possible the case of the W or the spaces are being read oddly? Have you tried seaching for other substrings? You've probably tried these methods, but I'm trying to help from afar. How about looking for the hex values of the spaces - x20Wx20, as referenced in the first link below. I know you've probably also scoured the web, but here are some Borland pages, if they may help:: : http://support.borland.com/thread.jspa?threadID=2046&tstart=90: http://support.borland.com/thread.jspa?messageID=6024: http://www.functionx.com/bcb/topics/strings.htm: : The last one has to do with C++ Builder, but maybe there's something to trigger a solution.: : Sorry I can't be of more help. Good luck with it.: : Take Care,: Ed[/blue]: : Thankyou Ed,Headache over. Never worked with Hex before infact my programming is very rusty as I am updating a program I wrote years ago whilst studying c++. Thanks again for your help and patience, your a STAR!! ;-)RegardsGraham

: : : Hi Ed, It would appear not. I think strstr() is for character strings and at this stage I cannot convert my ansistring LineToCheck into a character string to do the check. I can't understand why AnsiPos or Pos won't find the " W " correctly.: : : : : : Graham: : : : : [blue]: : Is it possible the case of the W or the spaces are being read oddly? Have you tried seaching for other substrings? You've probably tried these methods, but I'm trying to help from afar. How about looking for the hex values of the spaces - x20Wx20, as referenced in the first link below. I know you've probably also scoured the web, but here are some Borland pages, if they may help:: : : : http://support.borland.com/thread.jspa?threadID=2046&tstart=90: : http://support.borland.com/thread.jspa?messageID=6024: : http://www.functionx.com/bcb/topics/strings.htm: : : : The last one has to do with C++ Builder, but maybe there's something to trigger a solution.: : : : Sorry I can't be of more help. Good luck with it.: : : : Take Care,: : Ed[/blue]: : : : : Thankyou Ed,: Headache over. Never worked with Hex before infact my programming is very rusty as I am updating a program I wrote years ago whilst studying c++. Thanks again for your help and patience, your a STAR!! ;-): Regards: Graham:

Is it possible that the string is in Unicode while you are searching ASCII or something? You can detect that with a hex editor.Btw, ever tried using regular expressions? Little hard to bite at at first, but once you get the hang of it, they're great to search strings.