IF Node contains character

How would i use the IF node to filter out the rows for which a column has the Characters / or ; in it (Contains anywhere in the value)

If it contains either of those characters it should get split and be repeated on the nodes that come after

Sorry I’m using mobile. Managed to create workflow on mobile itself.

Basically if the input contains ; or / it’ll send to true branch.

You can copy paste the below code into workflow editor to check it.

{
  "name": "Test If",
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        150,
        200
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "WithComma",
              "value": "Hello/World"
            },
            {
              "name": "Normal",
              "value": "Hello world"
            },
            {
              "name": "WithCol",
              "value": "Hello; World"
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        330,
        210
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$node[\"Set\"].parameter[\"values\"][\"string\"][0][\"value\"]}}",
              "operation": "contains",
              "value2": "/"
            },
            {
              "value1": "={{$node[\"Set\"].json[\"WithCol\"]}}",
              "value2": ";"
            }
          ]
        },
        "combineOperation": "any"
      },
      "name": "IF",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        490,
        230
      ]
    },
    {
      "parameters": {},
      "name": "NoOp",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        700,
        150
      ]
    },
    {
      "parameters": {},
      "name": "NoOp1",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        710,
        280
      ]
    }
  ],
  "connections": {
    "Set": {
      "main": [
        [
          {
            "node": "IF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF": {
      "main": [
        [
          {
            "node": "NoOp",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "NoOp1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {},
  "id": "39"
}

I tried that

  "nodes": [
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "xxxxxxxxx",
              "operation": "notContains",
              "value2": "/"
            },
            {
              "value1": "xxxxxxxxx",
              "operation": "notContains",
              "value2": ";"
            },
            {
              "value1": "xxxxxxxxx",
              "operation": "notContains",
              "value2": ","
            }
          ]
        },
        "combineOperation": "any"
      },
      "name": "Multiple",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1410,
        410
      ]
    }
  ],
  "connections": {}
}```

But for some reason it doesnt work with my data

Which is mostly xxx xxxx / xxxx xxxx / xxxxx
Or the same with either a comma or a ; 

It doesnt match

Can you share the example data? It’s hard to understand and proceed further.

In which format? Copying the JSON from N8N seems to be a no-go

You still here?

Hey @Damian_K!

Did you find a solution?

No i didnt :frowning:

Hey @Damian_K!

Let me know if the following example helps. Since I don’t know what kind of data is returned to you, I am using the set node to create the data. In the IF node, I’ve set the Combine to All. This option will only return true if both the conditions are satisfied. In your case, the data not containing / and ;.

{
  "nodes": [
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "data 1",
              "value": "some random / data containing / data"
            },
            {
              "name": "data 2",
              "value": "some more; data about some; data"
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$node[\"Set\"].json[\"data 1\"]}}",
              "operation": "notContains",
              "value2": "/"
            },
            {
              "value1": "={{$node[\"Set\"].json[\"data 2\"]}}",
              "operation": "notContains",
              "value2": ";"
            }
          ]
        }
      },
      "name": "Multiple",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        647,
        296
      ]
    }
  ],
  "connections": {
    "Set": {
      "main": [
        [
          {
            "node": "Multiple",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Run it and you will see the issue:

{
  "nodes": [
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "data 1",
              "value": "some random / data containing / data"
            },
            {
              "name": "data 2",
              "value": "some more; data about some; data"
            },
            {
              "name": "data 3",
              "value": "test data"
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        950,
        700
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$node[\"Set\"].json[\"data 1\"]}}",
              "operation": "notContains",
              "value2": "/"
            },
            {
              "value1": "={{$node[\"Set\"].json[\"data 2\"]}}",
              "operation": "notContains",
              "value2": ";"
            }
          ]
        },
        "combineOperation": "any"
      },
      "name": "Multiple",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1150,
        690
      ]
    }
  ],
  "connections": {
    "Set": {
      "main": [
        [
          {
            "node": "Multiple",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

:stuck_out_tongue:

@harshil1712 have you seen it doesnt actually filter?

@Damian_K It’s doing what is suppose to do.

data1: some random / data containing / data

data2: some more; data about some; data

If (data1 does not contain /) || (data2 does not contain :wink:

if you evaluate that

if ((false) || (false))

if (false)

Then it goes to the false output

Probably you want to change the set node for a function node. Check the example below. It should do what you wanted to do.

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        300,
        280
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$node[\"Function\"].json[\"data\"]}}",
              "operation": "contains",
              "value2": "/"
            },
            {
              "value1": "={{$node[\"Function\"].json[\"data\"]}}",
              "operation": "contains",
              "value2": ";"
            }
          ]
        },
        "combineOperation": "any"
      },
      "name": "Multiple",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        950,
        280
      ]
    },
    {
      "parameters": {},
      "name": "NoOp",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1310,
        100
      ]
    },
    {
      "parameters": {},
      "name": "NoOp1",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1300,
        430
      ]
    },
    {
      "parameters": {
        "functionCode": "return [\n  {\n    json: {\n      data: 'some random / data containing / data',\n    }\n  },\n    {\n    json: {\n      data: 'some more; data about some; data',\n    }\n  },\n      {\n    json: {\n      data: 'test data',\n    }\n  }\n]"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        650,
        280
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Multiple": {
      "main": [
        [
          {
            "node": "NoOp",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "NoOp1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Function": {
      "main": [
        [
          {
            "node": "Multiple",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Oh with what i sent back there’s also “Data 3” which is being outputted in the same category

I just tried out what you sent, Funny to see that Contains does work, but “Doesnt contain” doesnt but this will probably work