Jump to content

Recommended Posts

Posted (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 by FireFox
Posted (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 by cageman
  • Moderators
Posted

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.

Posted (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 by FireFox
  • Moderators
Posted

@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 :)

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.

Posted

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 file

So 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 StringInStr

Thanks for answers

Posted

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]

Posted

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 :)

Posted (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 by FireFox
Posted

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]

Posted

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 :)
Posted

...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 :)
Posted

Any chance in you getting more explicit and give us an example of the "before" and "After" situation like Smoke_N requested?

Jos

Im 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"

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...