Regex to match valid Java path identifier -
suppose *a* java identifier. regex match things this:
\#a \#a.a.a (a number of times)
but not this:
\#a. (ending dot)
so in phase this: "#a.a less #a." match first \#a.a (because doesn't end dot).
this regex:
\#[a-za-z_$][\\w$]*(\\.[a-za-z_$][\\w$]*)*
almost job, matches last case too.
thank you.
marcos
you got right minor adjustments needed. consider regex:
#[a-za-z_$][\w$]*(?:\.[a-za-z_$][\w$]*)*(?!\w*\.) live demo: http://www.rubular.com/r/kjbsjkhhtv
translated java:
(?i)#[a-z_$][\\w$]*(?:\\.[a-z_$][\\w$]*)*(?!\\w*\\.)
Comments
Post a Comment