Parse pattern matches (or, in general, evaluates the rules) from left to right. You can visualize this with a position arrow, which points before the input at the start of the rules block:
When rules are matched, the parse position is moved. After the first pattern we get:
Then the some digit pattern processes the rest of the input, the parse position is at the end of the input, and true is returned:
If the input contains one (or more) spaces, there is no match:
parse "XY 2915" ["XY" some digit] ;== false
To make it match again, use space:
parse "XY 2915" ["XY" space some digit] ;== true
Or you could just skip the space character (or any character for that matter) with skip:
parse "XY 2915" ["XY" skip some digit] ;== true
If you want to skip several characters or a range, use a number or a number range before skip:
parse "XYabc2915" ["XY" 3 skip some digit] ;== true
parse "XY2915" ["XY" 0 3 skip some digit] ;== true
When you are interested in only one pattern in your input (such as ID in the following example), use skip like this:
program: {
ID: 121.34
Version: 1.2.3-5.6
Description: "This program calculates ..."
}
id: [3 digit dot 2 digit]
parse program [some [ id | skip]] ;== true
probe value ;== "121.34"
Note that dot is a built-in character—dot ;== #".".
As we will see in the following section, if we need the value of ID, we can copy it to a variable value as follows:
parse program [some [copy value id | skip]] ;== true
probe value ;== "121.34"