User Profile

Collapse

Profile Sidebar

Collapse
kam5438mak
kam5438mak
Last Activity: Oct 30 '13, 01:50 PM
Joined: Oct 24 '13
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Had fun Figuring it out myself. I just changed the logic a bit to use 2 arrays but skipping the i values in the for loop.

    Code:
     my $data = 'aa12ab123ac34ad23ae321ca21cb234za123zb12zd12'
      my @values1 = split(/(\d+)/, $data);
      my @values2 = split(/(\d+)/, $data);
    
    for (my $i=0; $i < @values1; $i++) {
      if ($values1[$i] eq "aa"){
       if ($values2[$i+1] == 0){
          print "Yay\n";
    ...
    See more | Go to post
    Last edited by Rabbit; Oct 25 '13, 05:02 PM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.

    Leave a comment:


  • kam5438mak
    started a topic extract numbers and text from a long string
    in Perl

    extract numbers and text from a long string

    I have a long string from which I would like to separate words and the next numbers and store them in arrays if possible

    String = aa12ab123ac34ad 23ae321ca21cb23 4za123zb12zd12

    text usually is 2 characters long but the digits vary in length 2-4 digits
    I would like to store them as
    alpha[1]=aa
    number[1]=12
    alpha[2]=ab
    number[2]=123
    .
    .
    .
    alpha[n]=zd
    ...
    See more | Go to post
No activity results to display
Show More
Working...