Regex Find last word between comma -


i have : "my item1,item2,item3,item4,"

i want answer : "item4"

i use :

    (?<=\,).*(?=\,$) 

but returns me : "item2,item3,item4"

how can last ?

i know lazy sign ? , i'm not able use it.

thanks help.

use [^,]* instead of .* since . match character comma. here non-greedy form .*? won't work.

(?<=,)[^,]*(?=,$) 

Comments

Popular posts from this blog

symfony - TEST environment only: The database schema is not in sync with the current mapping file -

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -