Assigning Unique Variables for Each Regex

I need to assign each regex match to its own unique variable.
For example:

First <h2> match becomes title1
Second <h2> match becomes title2
First <p> match becomes paragraph1
And so on…

Input

<h2>Lorem Ipsum Dolor</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eget dapibus tortor, vitae finibus arcu.</p>

Example Html code i would like to send to wordpress

<!-- wp:heading -->
 <h2 class="wp-block-heading"><strong>{{ $json.regexTitles1 }}</strong></h2>
 <!-- /wp:heading -->> 
 <!-- wp:image -->
 <img src="" alt="{{ $('Airtable').item.json.Image[0].url }}"
 <!-- /wp:image -->> 
 <!-- wp:paragraph -->
 <p>{{ $json.regexParagraphs1 }}</p>
 <!-- /wp:paragraph →

Information on your n8n setup
n8n version: 1.59.4
Database (default: SQLite): SQLite
n8n EXECUTIONS_PROCESS setting (default: own, main): main
Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
Operating system:

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hey @Pegazse , you are already called the properties regexTitles and regexParagraphs. You need to stick to those names instead of changing to regexTitles1 and regexParagraphs1 in Wordpress node.

Your Split Out node is expected to have the output in the form

[
  {
    "regexTitles": "Title1",
    "regexParagraphs": "Paragraph1"
  },
  {
    "regexTitles": "Title2",
    "regexParagraphs": "Paragraph2"
  }
]

Thus in the Wordpress node you would have something like

<!-- wp:heading -->
 <h2 class="wp-block-heading"><strong>{{ $json.regexTitles }}</strong></h2>
 <!-- /wp:heading -->> 
. . .
 <!-- wp:paragraph -->
 <p>{{ $json.regexParagraphs }}</p>
 <!-- /wp:paragraph →
2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.