Sign in to follow this  
Followers 0
FireFox

[RESOLVED] Hard script with string functions

22 posts in this topic

#1 ·  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

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites



#2 ·  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

Share this post


Link to post
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 :)

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.

Share this post


Link to post
Share on other sites

#4 ·  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

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
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..)


[right]~What can I say, I'm a Simplistic person[/right]

Share this post


Link to post
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 :)


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

I wish you good luck at this :)


[right]~What can I say, I'm a Simplistic person[/right]

Share this post


Link to post
Share on other sites

#11 ·  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

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
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.


[right]~What can I say, I'm a Simplistic person[/right]

Share this post


Link to post
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 :)

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

...this is so very confusing.

Can't you just use StringReplace()? Replace that something with nothing.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

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

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
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


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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"

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

@Jos

Dont know I just tried all stringfunctions but not this one LOL :)


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0