Eve Support Community
Forums
Resources
Development, & Software Talk
Spliting variables|
Go
![]() |
New
![]() |
Find
![]() |
Notify
![]() |
Tools
![]() |
Reply
![]() |
|
|
Groupee Member |
I would like to split a variable into an array so that each section has three characters in it. Example:
This is a test variable. Thi I know that the number of characters will allways be divisible by 3. ------------------ |
||
|
|
Groupee VIP |
Well if you want every 3 characters to go into each element of an array you can do something like this:
my(@array) = "characters here" =~ /^([A-Za-z]{3})+$/; -Marc |
|||
|
|
Groupee Member |
That only loads the last 3 characters into the array, and how can I adapt it to work with all ASCII characters?
------------------ [This message has been edited by eNnihilate (edited 07-15-2000).] |
|||
|
|
Groupee VIP |
Well, just change [A-Za-z] to any characters that should be valid. If you want all characters, including nonprintables and whitespace, then just switch the [A-Za-z] to a '.'.
my(@array) = "characters here" =~ /^(.{3})+$/; -Marc |
|||
|
|
Groupee Member |
Thanks!
------------------ |
|||
|
| Previous Topic | Next Topic | powered by eve community |
| Please Wait. Your request is being processed... |
|
Eve Support Community
Forums
Resources
Development, & Software Talk
Spliting variables
