Joseph
Guest
the following wcmatch command code applied to strings that contain numbers (between 0 and 9) could deceive.
e.g. I define the str string:
(setq str "var1 var2 var3 var4 var5")
I therefore apply some comparisons and echo the result.
1) (wcmatch str "*var[2-59]*") ->t
2) (wcmatch str "*var[6-89]*) >Nil
(wcmatch str"[6-92]**
incorrect reasoning:
1) as t comes out, I am tempted to deduce that it is right because in the range from var2 to var99 there is at least one string between var1 and var5.
2) as nil comes out, even here I am tempted to deduce that it is right because the range from var6 to var89 is completely external to the range between var1 to 5.
3) according to the previous reasoning I would have expected nil, because the range from var6 to var92 is completely external to that from var1 to var5.
rereading the help well I realized that wcmatch compares a character at a time, so the code [6-92] must be read in this way: interval between var6 and var9 and the string var2; therefore the substrings to compare with the str string are:
var6, var7, var8,var9 and var2, and it is the latter that brings out the result t being between var1 and var5.
e.g. I define the str string:
(setq str "var1 var2 var3 var4 var5")
I therefore apply some comparisons and echo the result.
1) (wcmatch str "*var[2-59]*") ->t
2) (wcmatch str "*var[6-89]*) >Nil
(wcmatch str"[6-92]**
incorrect reasoning:
1) as t comes out, I am tempted to deduce that it is right because in the range from var2 to var99 there is at least one string between var1 and var5.
2) as nil comes out, even here I am tempted to deduce that it is right because the range from var6 to var89 is completely external to the range between var1 to 5.
3) according to the previous reasoning I would have expected nil, because the range from var6 to var92 is completely external to that from var1 to var5.
rereading the help well I realized that wcmatch compares a character at a time, so the code [6-92] must be read in this way: interval between var6 and var9 and the string var2; therefore the substrings to compare with the str string are:
var6, var7, var8,var9 and var2, and it is the latter that brings out the result t being between var1 and var5.