boolean (Editor editor, int offset, char c) { CharSequence text = editor.getDocument().getCharsSequence(); if (offset < 2) return false; if (c != '{' || text.charAt(offset - 2) != '$') return false; if (offset < text.length()) { char next = text.charAt(offset); if (next == '}') return false; if (Character.isLetterOrDigit(next)) return false; } return true; }