Quantopian's community platform is shutting down. Please read this post for more information.
Back to Community
Tutorial 11 - how does the .matches() method work?

How does the .matches() method below work? What specifically do all of the symbols mean?

not_lp_name = ~Fundamentals.standard_name.latest.matches('.* L[. ]?P.?$')

1 response

'.' - this is for find matches on multiple lines '*' - matching on repetitions e.g., in this case, LP or LPP will be a match for LP 'L' - this is the first part we are looking for '[.]' - this is for matching the '.' symbol '?' - this is for the preceding characters, 'L' and '.', the '?' allows for matching of 'L' or 'L.', think of It as and or '$' - signifies the match needs to be the only thing at the end, so L.P. or LP (and the other variations via '?') but nothing else can come after

Source: https://docs.python.org/3.5/library/re.html#re.DOTALL
Check 6.2.1.