Reply to Re: [PHP] split or explode quoted strings

Your name:

Reply:


Posted by Robin Vickery on 11/14/05 18:03

On 11/14/05, Ördögh László <ordoghl@gmail.com> wrote:
> Hello,
>
> I would like to split or explode strings in a way that
> quoted strings inside the strings should remain.
> e.g.:
>
> "first second \"third third\" fourth \"fifth fifth fifth\""
>
> after the split I need:
>
> "first"
> "second"
> "third third"
> "fourth"
> "fifth fifth fifth"

How about something like this?

<?php

$singleQuoted = "(?:'(?:[^'\\\\]|\\\\.)*')";
$doubleQuoted = '(?:"(?:[^"\\\\]|\\\\.)*")';

$re = "/$singleQuoted|$doubleQuoted|\S+/s";

preg_match_all($re, $text, $quotedWords);

print_r($quotedWords);

?>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация