List Info

Thread: Need help with Regex for tags




Need help with Regex for tags
user name
2008-01-21 15:06:48
Hi there,

I'm hoping someone can help out, or has done this before.

I need a regex expression for an application to add tags.

There are a bunch of rules for my tagging.
1.  Any words separated by spaces are each tags (i.e. : tag1
tag2
tag3 )
2.  Any groups of words within quotes are a single tag (i.e.
"tag1a
tag1b" tag2 )
3.  Any groups of words separated by commas are a single tag
(i.e.
tag1a tag1b tag1c, tag2 tag3 )

I'm having troubles doing it in a single step.

Here's what I have so far to separate tags withing quotes
and tags
separated by spaces

$string = 'Jeff "orang e" happy "orang
ewww"';
echo "ORIG : " . $string .
"<BR>";
$replaced =
preg_replace('{"([ws]+)"|([w]+)}', '|$0|',
$string);
$replaced = preg_replace("(")",
"", $replaced );
echo "REPL : " . $replaced  .
"<BR>";

Thanks for any help
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )