Eve For Enterprise    Eve Support Community    Forums  Hop To Forum Categories  Resources  Hop To Forums  Development, & Software Talk    Spliting variables

Moderators: Mark Badolato
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Groupee Member
Posted
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
s i
s a
te
st
var
iab
le.

I know that the number of characters will allways be divisible by 3.

------------------
Alec H. Mackenzie
eNnihilate
amackenz@yahoo.com
Programmers' Lounge

 
Posts: 96 | Location: Bowdoinham, Maine, USA | Registered: March 29, 2000Reply With QuoteEdit or Delete MessageReport This Post
Groupee VIP
Posted Hide Post
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

 
Posts: 1063 | Location: Fairfax, VA | Registered: February 02, 1999Reply With QuoteEdit or Delete MessageReport This Post
Groupee Member
Posted Hide Post
That only loads the last 3 characters into the array, and how can I adapt it to work with all ASCII characters?

------------------
Alec H. Mackenzie
eNnihilate
amackenz@yahoo.com
[URL=http://www.gwi.net/thelounge/]

[This message has been edited by eNnihilate (edited 07-15-2000).]

 
Posts: 96 | Location: Bowdoinham, Maine, USA | Registered: March 29, 2000Reply With QuoteEdit or Delete MessageReport This Post
Groupee VIP
Posted Hide Post
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

 
Posts: 1063 | Location: Fairfax, VA | Registered: February 02, 1999Reply With QuoteEdit or Delete MessageReport This Post
Groupee Member
Posted Hide Post
Thanks!

------------------
Alec H. Mackenzie
eNnihilate
amackenz@yahoo.com
Programmers' Lounge

 
Posts: 96 | Location: Bowdoinham, Maine, USA | Registered: March 29, 2000Reply With QuoteEdit or Delete MessageReport This Post
 Previous Topic | Next Topic powered by eve community  
 

Eve For Enterprise    Eve Support Community    Forums  Hop To Forum Categories  Resources  Hop To Forums  Development, & Software Talk    Spliting variables