tags:

views:

26

answers:

1

Hi,

I have several keywords (1~3 words) stored in <MTEntryKeywords> field separated by commas. I want to take out the first keyword from MTEntryKeywords.

Example 1:

In the Keywords field I have entered: gadgets,phone,apple,

Want to display: gadgets

Example 2:

In the Keywords field I have entered: food,coffee,apple,

Want to display: food

Any ideas?

+1  A: 

This is untested, but something like this should do the trick (assuming you're using a recent enough version of MT)

<mt:entrykeywords regex_replace="/^([^,]+)(,.*)?$/","$1">

Basically, the regular expression there is saying "keep only everything up to, but not including, the first comma".

rayners
It works great! Thanks for your help
Maca