Professional Web Applications Themes

Another regex question - PHP Development

Hello, I'm trying to regex an expression like this: var1: val11 val12 ... val1N var2: val21 val22 ... val2M ... varI: valI1 ... valIJ to get a something like this: var1: val11 val12 ... val1N var2: val21 val22 ... val2M .. .. .. varI: valI1 ... valIJ for example a multiple array. Any ideas...? Thanks, Sebastián Araya...

  1. #1

    Default Another regex question

    Hello,


    I'm trying to regex an expression like this:

    var1: val11 val12 ... val1N var2: val21 val22 ... val2M ... varI: valI1 ... valIJ

    to get a something like this:

    var1: val11 val12 ... val1N
    var2: val21 val22 ... val2M
    ..
    ..
    ..
    varI: valI1 ... valIJ

    for example a multiple array.

    Any ideas...? Thanks,

    Sebastián Araya
    Sebastian Guest

  2. #2

    Default Re: Another regex question

    We need a more detailed example than that in order to be able to help you. I
    can't see any pattern in the examples you gave us so it's very likely that
    the expression we would develope would be wrong.

    Either way.. this might be what you're looking for:

    <?php
    $string = "var1: val11 val12 ... val1N var2: val21 val22 ... val2M ... varI:
    valI1 ... valIJ";
    $new_string = ereg_replace(" ([a-zA-Z0-9]+)\:", "\n\\1:", $string);
    echo $new_string;
    ?>

    --
    Erik Andersson ( E.N.E IT - Australia )
    http://www.eneit.com/
    - Australian, high quality web hosting from AU$4.95, all features included.

    "Sebastian Araya" <com.ar> wrote in message
    news:google.com... 
    .... valIJ 


    Erik Guest

  3. #3

    Default Re: Another regex question

    Thank you!

    Although I can't explain myself, your solution is brilliant.

    Thanks and Happy New Year!

    Sebastián Araya
    http://www.numisys.com.ar/

    "Erik Andersson" <com> wrote in message news:<3fee23f8$0$904$brisbane.pipenetworks.com.au> ... 
    Sebastian Guest

Similar Threads

  1. regex question
    By Math55 in forum PERL Beginners
    Replies: 19
    Last Post: July 21st, 06:22 PM
  2. [newbie] regex question
    By Luc in forum PHP Development
    Replies: 5
    Last Post: December 30th, 08:43 AM
  3. regex conditional question
    By Jonathan Driller in forum PERL Miscellaneous
    Replies: 5
    Last Post: August 19th, 09:59 PM
  4. Simple regex question
    By Gunnar Hjalmarsson in forum PHP Development
    Replies: 9
    Last Post: August 15th, 12:35 AM
  5. Regex question...
    By Greg Bacon in forum PERL Miscellaneous
    Replies: 1
    Last Post: July 15th, 09:21 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139