Cheatah: preg_split - wie nach ; trennen aber &xxxx; ausklammern?

Beitrag lesen

Hi,

Ausgenommen sein sollen aber HTML Formatierungen

wenn ich dazu mal die Perl-Doku zitieren darf (perldoc perlfaq4):

"""
How can I split a [character] delimited string except when inside [character]?

[...]
Due to the restriction of the quotes, this is a fairly complex problem. Thankfully, we have Jeffrey Friedl, author of a highly recommended book on regular expressions, to handle these for us. He suggests (assuming your string is contained in $text):

@new = ();
     push(@new, $+) while $text =~ m{
         "([^"\]*(?:\.[^"\]*)*)",?  # groups the phrase inside the quotes
       | ([^,]+),?
       | ,
     }gx;
     push(@new, undef) if substr($text,-1,1) eq ',';
"""

Für PHP ist das Problem identisch, der explizite Code natürlich nicht.

Cheatah

--
X-Will-Answer-Email: No
X-Please-Search-Archive-First: Absolutely Yes