HPlogo System Debug Reference Manual > Appendix A Patterns and Regular Expressions

Expression Closure (Match Zero or More of the Previous Expressions)

MPE documents

Complete PDF
Table of Contents
Index

E0201 Edition 4 ♥
E0300 Edition 3
E0692 Edition 3

Any regular expression that matches a single character (that is, everything but "^" and "$") can be followed by the character "*" to make a regular expression that matches zero or more successive occurrences of the single character pattern. The resulting expression is called a closure. For example, "x*" matches zero or more x's; "xx*" matches one or more "x's"; "[a-z]*" matches any string of zero or more lowercase letters. If there is a choice of the number of characters to be matched, the longest possible string is used even when a match with the null string is equally valid. "[a-zA-Z]*" matches an entire word (which may be a null string); "[a-zA-Z][a-zA-Z]*" matches at least an entire word (one or more letters but not a null string); and ".*" matches a whole line (which may be a null string). Any ambiguity in deciding which part of a line matches an expression is resolved by choosing the match beginning with the leftmost character, then choosing the longest possible match at the point. So "[a-zA-Z][a-zA-Z0-9_]*" matches the leftmost Pascal identifier on a line, "(.*)" matches anything between parentheses (not necessarily balanced), and "..*" matches an entire line of one or more characters but not a null string.




Character Classes (Match Any One of the Following Characters)


Technical Summary