in reply to Re: Multiline Regex
in thread Multiline Regex
Note: split /\n/ is only an acceptable of splitting text into lines if you don't care about eliminating trailing blank lines.
$str = "this\nis my short\nstring\n\n"; $i=0; for (split /\n/, $str) { print(++$i, ": $_\n"); } print("\n"); $i=0; for ($str =~ /.*\n|.+/g) { # Just like <> print(++$i, ": $_"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Multiline Regex
by johngg (Canon) on Oct 09, 2008 at 10:43 UTC | |
|
Re^3: Multiline Regex
by moritz (Cardinal) on Oct 09, 2008 at 09:56 UTC | |
by ikegami (Patriarch) on Oct 09, 2008 at 10:02 UTC | |
by moritz (Cardinal) on Oct 09, 2008 at 10:24 UTC | |
by ikegami (Patriarch) on Oct 09, 2008 at 10:44 UTC |