This is a line of code I found :
if(!word.matches("[a-zA-Z]{"+word.length()+"}")) return;
Specifically what does {"+word.length()+"}
do, what's the logic behind it, and where can I read more about it?
Curly braces here mean that number of symbols, for example {4} means exactly four symbols. Here you specify entire string (inserting the length of it) to consist of small or large latin letters. Also you can specify {2-4} for example, meaning interval of number of letters that match given pattern. Hope this helps.
You are misreading the parameters... this:
"[a-zA-Z]{"+word.length()+"}"
is the same as
"[a-zA-Z]{" // this is a string
+
word.length() // this is getting an integer( is the length of the string word)
+
"}" //another litt. string.
so you are technically concatenating 2 strings and putting in the middle a number...
just that
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.