Jump to content

[RESOLVED] Hard script with string functions


FireFox
 Share

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Moderators

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

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
Link to comment
Share on other sites

  • Moderators

@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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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
Link to comment
Share on other sites

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

  • Developers

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

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"
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...