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

gcc - MinGW's ld cannot perform PE operations on non PE output file -

How to connect android app to App engine -

hadoop - Running Map Reduce Job shows error - Mkdirs failed to create /var/folders/ -