diff --git a/framework-docs/modules/ROOT/pages/core/expressions/language-ref/variables.adoc b/framework-docs/modules/ROOT/pages/core/expressions/language-ref/variables.adoc index 11874bd75f3..96d75477d83 100644 --- a/framework-docs/modules/ROOT/pages/core/expressions/language-ref/variables.adoc +++ b/framework-docs/modules/ROOT/pages/core/expressions/language-ref/variables.adoc @@ -6,11 +6,14 @@ are set by using the `setVariable()` method in `EvaluationContext` implementatio [NOTE] ==== -Valid variable names must be composed of one or more of the following supported +Variable names must be begin with a letter (as defined below), an underscore, or a dollar +sign. + +Variable names must be composed of one or more of the following supported types of characters. -* letters: `A` to `Z` and `a` to `z` -* digits: `0` to `9` +* letter: any character for which `java.lang.Character.isLetter(char)` returns `true` +* digit: `0` to `9` * underscore: `_` * dollar sign: `$` ==== diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/standard/Tokenizer.java b/spring-expression/src/main/java/org/springframework/expression/spel/standard/Tokenizer.java index 632cf4721b7..5ca7b3c30cc 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/standard/Tokenizer.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/standard/Tokenizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -93,8 +93,8 @@ class Tokenizer { pushCharToken(TokenKind.PLUS); } break; - case '_': // the other way to start an identifier - lexIdentifier(); + case '_': + lexIdentifier(); // '_' is another way to start an identifier break; case '-': if (isTwoCharToken(TokenKind.DEC)) { @@ -206,7 +206,7 @@ class Tokenizer { pushPairToken(TokenKind.SELECT_LAST); } else { - lexIdentifier(); + lexIdentifier(); // '$' is another way to start an identifier } break; case '>':