rtconner / laravel-tagging

Tag support for Laravel Eloquent models - Taggable Trait
MIT License
882 stars 168 forks source link

Added a backward compatible possibility to use a regular expression to split a string of tags #88

Closed Uebix closed 5 years ago

Uebix commented 8 years ago

Added a backward compatible possibility to use a regular expression (so different characters or more complex rules) to split a string of tags.

rtconner commented 8 years ago

Can you add a unit test, or give me a usage example and I will add the test.

Uebix commented 8 years ago

Hello, an example may be when you have more than one character used to delimit tags: [,;>|]. This happen when you have different strings sources for tags like in a CSV file of products and you want combine the column tags that are separated with ";" and the column categories names that are separated with ">" or "|" and I want insert as tags. An other solution is to use optional parameter in functions like tag and retag, but i think that a regular expression is more complete and extend the possibilities of the developer.

A complete different example is if you want use your package such as a simple index system for text and not as tagging. You pass the text and set the regular expression for split words in a text without spaces or other characters so the delimiter may be /[^a-zA-Z0-9]+/.

rtconner commented 8 years ago

I just wanted a line of code or two :)

rtconner commented 5 years ago

Can't have multiple delimiters, because the delimiter field is use to write. You build the slug with it.