Jump to content

StringSplit... kinda


Go to solution Solved by mikell,

Recommended Posts

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
Posted

 

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

Posted

 

:)

$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|    ]  }}"

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

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

Posted

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.

Posted

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

 

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
  • Recently Browsing   0 members

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