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

java - BeanIO write annotated class to fixedlength -

Using Java 8 lambdas/transformations to combine and flatten two Maps -

How to connect android app to App engine -