On Wed, May 05, 2004 at 02:26:25PM +0900, Tumurbaatar S. wrote:
> 
> There's an input string like "{str1,str2,...,strN}". I want to capture
> all these strings and due to complexity of them I use a preg_match_all()
> instead of simple split. A pattern for the matching strings is ready but
> I cannot imagine how to specify that strings are separated by commas
> and the last one is not followed by comma. For example, I'm afraid that
> this pattern "/^{(?:(pattern),)*|(pattern)?}$/" can match and capture
> properly constructed input string, but, in addition, this matches if
> the string end is ",}". Any ideas?

Why not just strip out the braces and explode on commas?  That'll be
lighter than regexps any day.  If the input is guaranteed to be
formatted the way you describe, you could do something like:

  $out = explode(",", substr($in, 1, strlen($in)-2));

-- 
  Paul Chvostek                                             <[EMAIL PROTECTED]>
  it.canada                                            http://www.it.ca/
  Free PHP web hosting!                            http://www.it.ca/web/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to