Regular Expression
| From: | Tumurbaatar S. | Date: | Wed, 05 May 2004 05:26:25 +0000 |
| Subject: | Regular Expression | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-185394@lists.php.net to get a copy of this message | ||
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?