Lyee Posted April 30, 2017 Share Posted April 30, 2017 (edited) Hello, I'm currently doin with numbers in notepad and when function FileReadLine read the line in Notepad I'm having the line with numbers (variable $line) but I have lot of numbers there and I need just 10~~: 206779,-10,4,2,0,60,0,0,D|256:284,192:256,1,144,4|0,0:0|0:0,0:0:0:0: How to define each number to variables after ',' and skip a certain number of '|' symbols.. Or I acutally can just define that line and then call numbers but I dont know how to do it. It's hard af. Can someoen help me? Thank you :/ Edited April 30, 2017 by Lyee Link to comment Share on other sites More sharing options...
jchd Posted April 30, 2017 Share Posted April 30, 2017 Please tell us which values you expect to obtain from processing the line in the example given. That would make it much easier to help you. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Lyee Posted April 30, 2017 Author Share Posted April 30, 2017 (edited) These: 206779,-10,4,2,0,60,0,0,D|256:284,192:256 From: 206779,-10,4,2,0,60,0,0,D|256:284,192:256,1,144,4|0,0:0|0:0,0:0:0:0: D|256:284, 192:256 convert to D,256, 284, 192, 256 so actually skip ':' and '|' symbols and replace with ',' so it actually can be possible with stringreplace func. D letter is most wanted too Edited April 30, 2017 by Lyee Link to comment Share on other sites More sharing options...
jchd Posted April 30, 2017 Share Posted April 30, 2017 If I understand your text, you just whish to replace columns and bars by commas. But this is not what I see in the "These" line. Please clarify. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Lyee Posted April 30, 2017 Author Share Posted April 30, 2017 fuu.. I need these numbers define as variables and call them from another function 206779,-10,4,2,0,60,0,0,D|256:284,192:256 X $num1, $num2, $num3, $num4, $num..... ($num1 = 206779) ($num2 = -10) ... .. . btw Sorry for my bad eng Im not enough good speaker Link to comment Share on other sites More sharing options...
jchd Posted April 30, 2017 Share Posted April 30, 2017 You can extract all numbers like this: $line = "206779,-10,4,2,0,60,0,0,D|256:284,192:256,1,144,4|0,0:0|0:0,0:0:0:0:" $aValues = StringRegExp($line, "-?\d+", 3) _ArrayDisplay($aValues) Then access values like this: $aValues[0], $aValues[1], $aValues[2], $aValues[3], ... This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Lyee Posted April 30, 2017 Author Share Posted April 30, 2017 Thats what I wanted.. Thank you a lot Link to comment Share on other sites More sharing options...
Lyee Posted April 30, 2017 Author Share Posted April 30, 2017 one more thing yet.. How can I see how much variables in $aValues I'm having? Link to comment Share on other sites More sharing options...
jchd Posted April 30, 2017 Share Posted April 30, 2017 UBound($aValues) will tell you that. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
kylomas Posted April 30, 2017 Share Posted April 30, 2017 Lyee, The Ubounds value of the array will give you the number of elements... local $numElements = ubound($aValues) - 1 kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
kylomas Posted April 30, 2017 Share Posted April 30, 2017 Oops!!...Hi JCHD... Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
jchd Posted April 30, 2017 Share Posted April 30, 2017 Remove the -1 since we look for the number of elements, not the index of the last one. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
kylomas Posted April 30, 2017 Share Posted April 30, 2017 @jchd - of course, thanks... @Lyee - a small example of accessing the array... #include <array.au3> $line = "206779,-10,4,2,0,60,0,0,D|256:284,192:256,1,144,4|0,0:0|0:0,0:0:0:0:" $aValues = StringRegExp($line, "-?\d+", 3) _ArrayDisplay($aValues) ConsoleWrite('The number of elements = ' & UBound($aValues) & @CRLF & 'The value of each is:' & @CRLF) For $i = 0 To UBound($aValues) - 1 ConsoleWrite(@TAB & 'Element # ' & $i + 1 & ' at offset ' & $i & ' = ' & $aValues[$i] & @CRLF) Next kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
iamtheky Posted April 30, 2017 Share Posted April 30, 2017 you could also just assign them (cool kids can do it in the regex, I take an extra loop) $line = "206779,-10,4,2,0,60,0,0,D|256:284,192:256,1,144,4|0,0:0|0:0,0:0:0:0:" $aValues = StringRegExp($line, "-?\d+", 3) For $i = 0 To UBound($aValues) - 1 assign("num" & $i , $aValues[$i]) Next consolewrite(eval("num0")& @CR) consolewrite(eval("num3")& @CR) consolewrite(eval("num5")) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Lyee Posted April 30, 2017 Author Share Posted April 30, 2017 Thank you guys, you helped me a lot <3 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