[Tutor] really basic - finding multiline chunk within larger chunk
Danny Yoo
dyoo at hashcollision.org
Tue Feb 16 23:56:05 EST 2016
Hi Bruce,
> For some reason, can't seem to return true on the find. I've pasted in
> http://fpaste.org/323521/, but the following is an example as well.
> (not sure if the psuedo code listed actually shows the chunks of text
> with the whitespace correctly.
As others have mentioned, pattern matching on tree structures by using
string comparison is a fragile approach, and the mismatch is probably
reflecting that fragility: it'll mismatch entirely even if a single
whilespace character is not the same as the pattern you're matching.
Looking at your input, I see that you're expecting to match the second
row of content:
>
> <TR>
> <TD align="LEFT" valign="TOP"></TD>
> <TD align="LEFT" valign="TOP"
> class="row_SectionLite"><STRONG>Required</STRONG></TD>
> <TD valign="TOP" class="row_SectionLite"></TD>
> <TD align="RIGHT" valign="TOP" class="row_SectionLite">
> Yes
> </TD>
> <TD align="RIGHT" valign="TOP"></TD>
> </TR>
>
where your pattern string is
>
> s2a='''<TR>
> <TD align="LEFT" valign="TOP"></TD>
> <TD align="LEFT" valign="TOP"
> class="row_SectionLite"><STRONG>Required</STRONG></TD>
> <TD valign="TOP" class="row_SectionLite"></TD>
> <TD align="RIGHT" valign="TOP" class="row_SectionLite">
> Yes
> </TD>
> <TD align="RIGHT" valign="TOP"></TD>
> </TR>'''
>
Huh. Unfortunately, I can't reproduce your failure: it appears to
match successfully for me. Example:
https://repl.it/Bn34/0
Can you reproduce this?
More information about the Tutor
mailing list