Seminko Posted September 15, 2014 Share Posted September 15, 2014 (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 September 15, 2014 by Seminko Link to comment Share on other sites More sharing options...
Gianni Posted September 15, 2014 Share Posted September 15, 2014 have you try with _StringBetween() ? Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Seminko Posted September 15, 2014 Author Share Posted September 15, 2014 OMG, I was sure there was a function that I've already seen. This is it! Let me try... Link to comment Share on other sites More sharing options...
mikell Posted September 15, 2014 Share Posted September 15, 2014 Regex can do that #Include <Array.au3> $str = "6||: [ |meatflycze|, |oze_g| ] }}" $res = StringRegExp($str, '\|(\w+)\|', 3) _ArrayDisplay($res) Link to comment Share on other sites More sharing options...
Seminko Posted September 15, 2014 Author Share Posted September 15, 2014 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 Link to comment Share on other sites More sharing options...
Danyfirex Posted September 15, 2014 Share Posted September 15, 2014 for and &. saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Gianni Posted September 15, 2014 Share Posted September 15, 2014 (edited) or try _ArrayToString() also Edited September 15, 2014 by Chimp Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Solution mikell Posted September 15, 2014 Solution Share Posted September 15, 2014 $str = "6||: [ |meatflycze|, |oze_g| ] }}" $str = StringReplace(StringRegExpReplace($str, '[^[:alpha:]_,]', ""), ",", ", ") Msgbox(0,"", $str) Link to comment Share on other sites More sharing options...
Seminko Posted September 15, 2014 Author Share Posted September 15, 2014 $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! Link to comment Share on other sites More sharing options...
Gianni Posted September 15, 2014 Share Posted September 15, 2014 $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| ] }}" Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Seminko Posted September 15, 2014 Author Share Posted September 15, 2014 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. Link to comment Share on other sites More sharing options...
Seminko Posted September 15, 2014 Author Share Posted September 15, 2014 Alrighty, FileOpen in the second mode does exactly that. Thanks again guys. Link to comment Share on other sites More sharing options...
MikahS Posted September 15, 2014 Share Posted September 15, 2014 Open the file in overwrite mode Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now