Sign in to follow this  
Followers 0
Seminko

StringSplit... kinda

13 posts in this topic

#1 ·  Posted (edited)

Hey fellas,

I have a string and please note it is going to be dynamic:

6||: [      |meatflycze|,      |oze_g|    ]  }}

What I need is to somehow extract the strings between these two characters: " | " and put them one after another. So the string above would become:

meatflycze, oze_g

Any ideas please?

Edited by Seminko

Share this post


Link to post
Share on other sites



have you try with _StringBetween() ?


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

OMG, I was sure there was a function that I've already seen. This is it!

Let me try...

Share this post


Link to post
Share on other sites

 

Regex can do that  :)

#Include <Array.au3>

$str = "6||: [      |meatflycze|,      |oze_g|    ]  }}"

$res = StringRegExp($str, '\|(\w+)\|', 3)
 _ArrayDisplay($res)

That is correct mister! Now I have to figure out a way how to put all elements of the array into a single string with a comma and a space in between

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

or try _ArrayToString() also

Edited by Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

 

:)

$str = "6||: [      |meatflycze|,      |oze_g|    ]  }}"

$str = StringReplace(StringRegExpReplace($str, '[^[:alpha:]_,]', ""), ",", ", ")
Msgbox(0,"", $str)

Hey mikell! Nice to see you again! And it indeed worked! :)

Very much appreciated guys!

Share this post


Link to post
Share on other sites

 

:)

$str = "6||: [      |meatflycze|,      |oze_g|    ]  }}"

$str = StringReplace(StringRegExpReplace($str, '[^[:alpha:]_,]', ""), ",", ", ")
Msgbox(0,"", $str)

 

shouldn't this string give 3 substrings? it gives 2 instead

$str = "6||: [      |meatf| |lycze|,      |oze_g|    ]  }}"

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

One more thing though. Is there a way to write the data into a txt file?

I know of FileWrite. But the next time the script is used I would like the previous data to be rewritten.

Share this post


Link to post
Share on other sites

Alrighty, FileOpen in the second mode does exactly that. Thanks again guys.

Share this post


Link to post
Share on other sites

Open the file in overwrite mode :)


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

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