CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
how to split the string with 2 bytes?

 



tack
Novice

Jan 13, 2003, 12:15 AM

Post #1 of 8 (1045 views)
how to split the string with 2 bytes? Can't Post

for example:

"abcdefg" >>-----change into---->>(ab,cb,de,fg)

do you know how to do it? help me ! Thanks alot!


thodi
stranger

Jan 13, 2003, 12:46 AM

Post #2 of 8 (1037 views)
Re: [tack] how to split the string with 2 bytes? [In reply to] Can't Post

You could use something like this:

Code
my $str = "abcdefgh"; 
my @parts = $str =~ /../g; # Repeatedly match two characters



tack
Novice

Jan 13, 2003, 12:57 AM

Post #3 of 8 (1037 views)
Re: [thodi] how to split the string with 2 bytes? [In reply to] Can't Post

your code is right.

thank you very much.


uatt
User

Jan 16, 2003, 3:52 PM

Post #4 of 8 (1028 views)
Re: [tack] how to split the string with 2 bytes? [In reply to] Can't Post

Just want to learn more what if getting

ab cd ef gh from

$string = "abcdefgh";


Paul
Enthusiast

Jan 17, 2003, 2:59 AM

Post #5 of 8 (1019 views)
Re: [uatt] how to split the string with 2 bytes? [In reply to] Can't Post


Quote
Just want to learn more what if getting

ab cd ef gh from

$string = "abcdefgh";


Pardon?

Are you asking a question?....if so then your answer is already three posts up.


(This post was edited by Paul on Jan 17, 2003, 3:00 AM)


uatt
User

Jan 17, 2003, 4:55 AM

Post #6 of 8 (1013 views)
Re: [Paul] how to split the string with 2 bytes? [In reply to] Can't Post

The answer in three post up is

ab bc cd de ef fg gh

whereas, I like

ab cd ef gh


Paul
Enthusiast

Jan 17, 2003, 7:53 AM

Post #7 of 8 (1009 views)
Re: [uatt] how to split the string with 2 bytes? [In reply to] Can't Post

I guess you are doing something wrong because it works fine for me...

ab cd ef gh


uatt
User

Jan 17, 2003, 3:15 PM

Post #8 of 8 (1002 views)
Re: [Paul] how to split the string with 2 bytes? [In reply to] Can't Post

yes, I am wrong...

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives