I am doing a string.replace in a simple table generation app I wrote, and I can't figure out how to match whitespace with /s, so I thought I would see if osmeone where would be kind enough to tell me what I am getting wrong.
This works: string = string.replace('<tr>\n <th class="table">Field One</th> \n <td>%FieldOneValue%</td>\n </tr>', '') You can see I had to actually put in space characters and linefeeds exactly as they are in the string. I tried these this: string = string.replace('<tr>\s*<th class="table">Field One</th>\s*<td> %FieldOneValue%</td>\s*</tr>', '') But this doesn't work. The doco for Python's regex suggests that \s should match any whitespace including newlines which is what I wanted, but just in case, I also tried this: string = string.replace('<tr>\n\s*<th class="table">Field One</th>\n \s*<td>%FieldOneValue%</td>\n\s*</tr>', '') Any help explaining why these are not working would be greatly appreciated. TIA nuffi -- http://mail.python.org/mailman/listinfo/python-list