Extract one table from a long HTML

What are you trying to achieve?

I’m trying to parse HTML data. But it is not easy as this HTML is very long and no tags come with unique ID.
I want to extract a specific table part like below. I tried to use Text parser > Match pattern, but couldn’t get the correct result.




<table border=“0” cellpadding=“0” cellspacing=“0” align=“left” style=“width:100%;border-top:3px solid #7342e8”>

… contents of the table I want to extract

</table>

Welcome to the Make community!

When reaching out for assistance with your regex pattern for a Text Parser module, it would be super helpful if you could share the actual text you’re trying to match. Screenshots of text can be a bit tricky, so if you could copy and paste the text example directly here, that would be awesome! It ensures we can run it against test patterns effectively. If there’s any sensitive info, feel free to change it to something fictional yet still valid by keeping the format intact.

Providing clear text examples saves time on both ends and helps us give you the best possible solution. Without proper examples, we might end up playing a guessing game, and nobody wants that as it is a waste of time! You are more likely to get a correct answer faster. So, help us help you by sharing those text snippets.

Please format the example text this way to preserve line breaks and special characters:

These are the two ways to format text so that it won’t be modified by the forum:

  • Method 1: Type code block manually

    Add three backticks ``` before and after the content/bundle, like this:

    ```
    content goes here
    ```

  • Method 2. Highlight and click the format button in the editor

Hope this helps! Let me know if there are any further questions or issues.

@samliew



<table border=“0” cellpadding=“0” cellspacing=“0” align=“left” style=“width:100%;border-top:3px solid #7342e8”>

… contents of the table I want to extract

</table>

Welcome to the Make community!

You can use a Text Parser “Match Pattern” module with this Pattern (regular expression):

<table[^>]+7342e8[^>]+>\s*(?<contents>[\w\W]*?)\s*<\/table>

Proof https://regex101.com/r/VatfWb/1

Important Info

  • :warning: Global match must be set to NO!

For more information, see Text Parser in the Make Help Center:

Match Pattern
The Match pattern module enables you to find and extract string elements matching a search pattern from a given text. The search pattern is a regular expression (aka regex or regexp), which is a sequence of characters in which each character is either a metacharacter, having a special meaning, or a regular character that has a literal meaning.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

I think I need to describe again.
This is an example of table that I want to extract from a HTML. Of course, items can be repeated.
But always, it starts with <table border=“0” cellpadding=“0” cellspacing=“0” align=“left” style=“width:100%;border-top:3px solid #7342e8”>
and ends with </table>

<table border="0" cellpadding="0" cellspacing="0" align="left" style="width:100%;border-top:3px solid #7342e8">

 <tbody><tr>

                                  <td width="90" height="43" style="padding-left:14px;border-bottom:1px solid #ebebeb;background-color:#f6f6f6;font-family:&#39;\00b098\00b214\00ace0\00b515&#39;,NanumGothic,&#39;\00b9d1\00c740\00ace0\00b515&#39;,Malgun Gothic,&#39;\00b3cb\00c6c0&#39;,Dotum,Helvetica,&#39;Apple SD Gothic Neo&#39;,Sans-serif;font-size:13px;color:#696969">space</td>

</tbody></table>

Sure thing, here’s how to match the entire table for all the same table type.

You can use a Text Parser “Match Pattern” module with this Pattern (regular expression):

(?<table><table border="0" cellpadding="0" cellspacing="0" align="left" style="width:100%;border-top:3px solid #7342e8">[\w\W]*?<\/table>)

Proof https://regex101.com/r/6dXeTT/1

Important Info

  • :warning: Global match must be set to YES!

Hope this helps! Let me know if there are any further questions or issues.

@samliew

3 Likes

Thank you so much the quick response. It works perfect!

No problem, glad I could help!

1. If anyone has a new question in the future, please start a new thread. This makes it easier for others with the same problem to search for the answers to specific questions, and you are more likely to receive help since newer questions are monitored closely.

2. The Make Community guidelines encourages users to try to mark helpful replies as solutions to help keep the Community organized.

This marks the topic as solved, so that:

  • others can save time when catching up with the latest activity here, and
  • allows others to quickly jump to the solution if they come across the same problem

To do this, simply click the checkbox at the bottom of the post that answers your question:

3. Don’t forget to like and bookmark this topic so you can get back to it easily in future!

@samliew