문제

I need to match variables that start with a lowercase letter and don't end in an underscore.

I have these three fields:

private String shouldFlag;
private String shouldntFlag_;
private String SHOULDNTFLAG;

With this pattern inverted: ^[a-z].*_$

Used with for fieldname in the following template:

class $Class$ { 
  $FieldType$ $FieldName$ = $Init$;
}

The problem is that SHOULDNTFLAG is still flagged. I tried using ^[a-z].*_$|^[A-Z].*$, but that did not match anything, let alone just shouldFlag. What am I doing wrong here?

도움이 되었습니까?

해결책

Assuming your variable names can only contain ASCII letters and digits plus the underscore, I would go with

\b[a-z]\w*\b(?<!_)

EDIT: ...and, as @Stefan pointed out, you need to select the "case-sensitive" option.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top