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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -