FireFox Posted December 3, 2008 Share Posted December 3, 2008 (edited) Hi, I want to split some text in a file with StringSplit and search some text and its ok with StringInStr but after ive found it how i delete string ? Here an example whats written in the file : C:\|0 // D:\|1 // A:\Folder|2 // I split this text with // and in split I search for example D:\|1 , how can i have return string with caracter from left and right for delete it ? Thanks for answers Edited December 6, 2008 by FireFox Link to comment Share on other sites More sharing options...
cageman Posted December 3, 2008 Share Posted December 3, 2008 (edited) Hi, I want to split some text in a file with StringSplit and search some text and its ok with StringInStr but after ive found it how i delete string ? Here an example whats written in the file : C:\|0 // D:\|1 // A:\Folder|2 // I split this text with // and in split I search for example D:\|1 , how can i have return string with caracter from left and right for delete it ? Thanks for answers i hope i understand your question: $string="C:\|0 // D:\|1 // A:\Folder|2 //" $array=StringSplit($string) ; you should look at the stringsplit function tho since im not sure what arguments it needs. if its what you mean stringsplit creates an array with: 4 strings: C:\|0 D:\|1 A:\Folder|2 + one empty "" you need #2 which is probably $array[1] or $array[2] or as smoke_n answers use StringTrimRight , StringTrimLeft to remove parts from the right/left gl! Edited December 3, 2008 by cageman Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 3, 2008 Moderators Share Posted December 3, 2008 Hi, I want to split some text in a file with StringSplit and search some text and its ok with StringInStr but after ive found it how i delete string ? Here an example whats written in the file : C:\|0 // D:\|1 // A:\Folder|2 // I split this text with // and in split I search for example D:\|1 , how can i have return string with caracter from left and right for delete it ? Thanks for answers You're question is more confusing than most noobs. StringTrim* functions is probably what you are after. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
FireFox Posted December 3, 2008 Author Share Posted December 3, 2008 (edited) i hope i understand your question: $string="C:\|0 // D:\|1 // A:\Folder|2 //" $array=StringSplit($string) ; you should look at the stringsplit function tho since im not sure what arguments it needs. if its what you mean stringsplit creates an array with: 4 strings: C:\|0 D:\|1 A:\Folder|2 + one empty "" you need #2 which is probably $array[1] or $array[2] gl! Thanks for your reply, But its harder like that because i know to do that... 1.Text in file can change so more arrays 2.Thats why i was asking for use with StringInStr to search good array Thanks for answer ! You're question is more confusing than most noobs. StringTrim* functions is probably what you are after.@SmOke_N I know Stringtrim, etc... but the string always change so I split arrays and I want to search in it with StringInStr and find the one I want Edited December 3, 2008 by FireFox Link to comment Share on other sites More sharing options...
toonboon Posted December 3, 2008 Share Posted December 3, 2008 What exactly do you want to delete? If You'd explain that to us it'd be way more clear. [right]~What can I say, I'm a Simplistic person[/right] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 3, 2008 Moderators Share Posted December 3, 2008 @SmOke_NI know Stringtrim, etc... but the string always change so I split arrays and I want to search in it with StringInStr and find the one I want And you're point being?You'd be better off to give a real life scenario example. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
FireFox Posted December 3, 2008 Author Share Posted December 3, 2008 What exactly do you want to delete? If You'd explain that to us it'd be way more clear. I explain more...I have listview and I can add some items in it and i write items in txt file.When I add item in listview I add "//" after for split them in txt fileSo if I select item and i want to delete it its ok for listview, but in file ?I think the better way is to split text with StringSplit and then search good array with StringInStrThanks for answers Link to comment Share on other sites More sharing options...
toonboon Posted December 3, 2008 Share Posted December 3, 2008 You don't need to use stringsplit, take a careful look at StringRegExpReplace() that should do the job (I'm not good at using that function, others are..) [right]~What can I say, I'm a Simplistic person[/right] Link to comment Share on other sites More sharing options...
FireFox Posted December 3, 2008 Author Share Posted December 3, 2008 You don't need to use stringsplit, take a careful look at StringRegExpReplace() that should do the job (I'm not good at using that function, others are..)Thanks its the best way to replace text i want to delete by nothing Link to comment Share on other sites More sharing options...
toonboon Posted December 3, 2008 Share Posted December 3, 2008 I wish you good luck at this [right]~What can I say, I'm a Simplistic person[/right] Link to comment Share on other sites More sharing options...
FireFox Posted December 3, 2008 Author Share Posted December 3, 2008 (edited) I wish you good luck at this Hum...It seems to don't work with sentence (from helpfile)The text to replace the regular expression matching text with. To insert matched group text, \0 - \9 (or $0 - $9) can be used as back-references.So i can't replace all my string Edited December 3, 2008 by FireFox Link to comment Share on other sites More sharing options...
toonboon Posted December 3, 2008 Share Posted December 3, 2008 haha, yup the StringRegExpReplace() function is a real fucking pain in the ass. I suggest pressing F1 in Scite and looking at the inbuilt tutorials in the helpfile that helps. [right]~What can I say, I'm a Simplistic person[/right] Link to comment Share on other sites More sharing options...
FireFox Posted December 6, 2008 Author Share Posted December 6, 2008 haha, yup the StringRegExpReplace() function is a real fucking pain in the ass. I suggest pressing F1 in Scite and looking at the inbuilt tutorials in the helpfile that helps.I want to be more clear : just want to delete sentence in a file Link to comment Share on other sites More sharing options...
trancexx Posted December 6, 2008 Share Posted December 6, 2008 ...this is so very confusing. Can't you just use StringReplace()? Replace that something with nothing. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
FireFox Posted December 6, 2008 Author Share Posted December 6, 2008 ...this is so very confusing.Can't you just use StringReplace()? Replace that something with nothing.Hum yes, I always search for difficult thing when I don't know how to do thanks Link to comment Share on other sites More sharing options...
Developers Jos Posted December 6, 2008 Developers Share Posted December 6, 2008 Any chance in you getting more explicit and give us an example of the "before" and "After" situation like Smoke_N requested? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
FireFox Posted December 6, 2008 Author Share Posted December 6, 2008 Any chance in you getting more explicit and give us an example of the "before" and "After" situation like Smoke_N requested? JosIm not on my computer right now but I can give you simple example Before (want to delete //D:\|1) "C:\|0//D:\|1//E:\|2" After "C:\|0//E:\|2" Link to comment Share on other sites More sharing options...
Developers Jos Posted December 6, 2008 Developers Share Posted December 6, 2008 .... and why would a simple StringReplace() not work in this example? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
FireFox Posted December 6, 2008 Author Share Posted December 6, 2008 @Jos Dont know I just tried all stringfunctions but not this one LOL Link to comment Share on other sites More sharing options...
Developers Jos Posted December 6, 2008 Developers Share Posted December 6, 2008 Sometimes its simple, all you really need to do is ask the right question. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now