помогите пожалуйста с регуляркой

Discussion in 'PHP' started by Sanic1977, 11 Oct 2013.

  1. Sanic1977

    Sanic1977 Banned

    Joined:
    29 Oct 2008
    Messages:
    98
    Likes Received:
    6
    Reputations:
    0
    помогите пожалуйста с регуляркой
    есть выр. test@email.com:password@216.12.200.131:25
    представить в виде
    216.12.200.131,25,test@email.com,password

    спасибо
     
  2. M@rkus

    M@rkus Banned

    Joined:
    25 Jul 2010
    Messages:
    46
    Likes Received:
    6
    Reputations:
    0
    А зачем вам вообще регулярки? Непроще
    PHP:
    <?php
    $input 
    "test@email.com:password@216.12.200.131:25";
    $dd explode(":",$input);
    $email $dd[0];
    $cc explode("@",$dd[1]);
    $pwd  $cc[0];
    $ip $cc[1];
    $port $dd[2];
    echo 
    "$ip,$port,$email,$pwd";
    ?>
     
  3. Kaimi

    Kaimi Well-Known Member

    Joined:
    23 Aug 2007
    Messages:
    1,759
    Likes Received:
    816
    Reputations:
    230
    Code:
    use strict;
    use warnings;
    
    my $str = 'test@email.com:password@216.12.200.131:25';
    
    $str =~ s/^(\S+?@\S+?):(.+?)\@((?:\d{1,3}\.){3}\d{1,3}):(\d{1,5})$/$3,$4,$1,$2/;
    print $str;
    
     
    _________________________
    1 person likes this.
  4. Sanic1977

    Sanic1977 Banned

    Joined:
    29 Oct 2008
    Messages:
    98
    Likes Received:
    6
    Reputations:
    0
    Всем спасибо, тема закрыта.
     
Loading...
Similar Threads - помогите пожалуйста регуляркой
  1. Brombus
    Replies:
    4
    Views:
    1,433
  2. ninja123
    Replies:
    6
    Views:
    1,383
  3. proroot
    Replies:
    3
    Views:
    1,205
  4. slaviklog
    Replies:
    3
    Views:
    1,264