I have a string which looks like below
answer = """
models sold in last 4 weeks
+---------------+
| pcid |
+---------------+
| 22bv03 |
| 3eer3d |
| fes44h2j555j |
| 4mee33ikj5sq1 |
| 99dkk3bvr32a |
| cv44trmq011sa |
| lo33xc1a |
+---------------+***For more information, please visit the company page.
"""
Now I need to extract just the table from the string such that the end result looks like
+---------------+
| pcid |
+---------------+
| 22bv03 |
| 3eer3d |
| fes44h2j555j |
| 4mee33ikj5sq1 |
| 99dkk3bvr32a |
| cv44trmq011sa |
| lo33xc1a |
+---------------+
Now I tried doing something like this
answer.split("***")[0].split("\n")[1]
But doing so, I only get the header against the expected table.
How do I ensure that I can only extract table from the string? Is there any regex that can be applied here?
+---------------+string, then get the substring till the last+---------------+string. See ideone.com/HNYsmN