Using "format" attempt to pull values from "string". The format must match the string contents exactly. If the value you're looking for is instead just a part of the string use search(). If ``evaluate_result`` is True the return value will be an Result instance with two attributes:
(format, string, extra_types=None, evaluate_result=True, case_sensitive=False)
| 941 | |
| 942 | |
| 943 | def parse(format, string, extra_types=None, evaluate_result=True, case_sensitive=False): |
| 944 | """Using "format" attempt to pull values from "string". |
| 945 | |
| 946 | The format must match the string contents exactly. If the value |
| 947 | you're looking for is instead just a part of the string use |
| 948 | search(). |
| 949 | |
| 950 | If ``evaluate_result`` is True the return value will be an Result instance with two attributes: |
| 951 | |
| 952 | .fixed - tuple of fixed-position values from the string |
| 953 | .named - dict of named values from the string |
| 954 | |
| 955 | If ``evaluate_result`` is False the return value will be a Match instance with one method: |
| 956 | |
| 957 | .evaluate_result() - This will return a Result instance like you would get |
| 958 | with ``evaluate_result`` set to True |
| 959 | |
| 960 | The default behaviour is to match strings case insensitively. You may match with |
| 961 | case by specifying case_sensitive=True. |
| 962 | |
| 963 | If the format is invalid a ValueError will be raised. |
| 964 | |
| 965 | See the module documentation for the use of "extra_types". |
| 966 | |
| 967 | In the case there is no match parse() will return None. |
| 968 | """ |
| 969 | p = Parser(format, extra_types=extra_types, case_sensitive=case_sensitive) |
| 970 | return p.parse(string, evaluate_result=evaluate_result) |
| 971 | |
| 972 | |
| 973 | def search( |