How do I remove words from a string if they appear in an array?

As a lot of stuff in Make there is some undocumented stuff. Looks like both flags cannot be used together.

{{replace(lower("this Without about test"); "/\b(a|about|actually|almost|also|although|always|am|an|and|any|are|as|at|be|became|become|but|by|can|could|did|do|does|each|either|else|for|from|had|has|have|hence|how|i|if|in|is|it|its|just|may|maybe|me|might|mine|must|my|neither|nor|not|of|oh|ok|when|where|whereas|wherever|whenever|whether|which|while|who|whom|whoever|whose|why|will|with|within|without|would|yes|yet|you|your)\b/g"; emptystring)}}

will work since the input text is lowercased first and all the words on the RegEx are also lower cased. Thanks @samliew for the correction to work around the inability to place both g and i modifiers into the expression.

You may want to use the Text Parser module also if you don’t want to do the workaround approach above.

Copy and paste this scenario snippet into your scenario canvas

This text will be hidden{
“subflows”: [
{
“flow”: [
{
“id”: 1,
“module”: “util:SetVariables”,
“version”: 1,
“parameters”: {},
“mapper”: {
“variables”: [
{
“name”: “test”,
“value”: “{{replace(lower("this Without about test"); "/\b(a|about|actually|almost|also|although|always|am|an|and|any|are|as|at|be|became|become|but|by|can|could|did|do|does|each|either|else|for|from|had|has|have|hence|how|i|if|in|is|it|its|just|may|maybe|me|might|mine|must|my|neither|nor|not|of|oh|ok|when|where|whereas|wherever|whenever|whether|which|while|who|whom|whoever|whose|why|will|with|within|without|would|yes|yet|you|your)\b/g"; emptystring)}}”
}
],
“scope”: “roundtrip”
},
“metadata”: {
“designer”: {
“x”: 0,
“y”: 0
},
“restore”: {
“expect”: {
“variables”: {
“items”: [
null
]
},
“scope”: {
“label”: “One cycle”
}
}
},
“expect”: [
{
“name”: “variables”,
“type”: “array”,
“label”: “Variables”,
“spec”: [
{
“name”: “name”,
“label”: “Variable name”,
“type”: “text”,
“required”: true
},
{
“name”: “value”,
“label”: “Variable value”,
“type”: “any”
}
]
},
{
“name”: “scope”,
“type”: “select”,
“label”: “Variable lifetime”,
“required”: true,
“validate”: {
“enum”: [
“roundtrip”,
“execution”
]
}
}
],
“interface”: [
{
“name”: “test”,
“label”: “test”,
“type”: “any”
}
]
}
},
{
“id”: 2,
“module”: “regexp:Replace”,
“version”: 1,
“parameters”: {},
“mapper”: {
“pattern”: “\b(a|about|actually|almost|also|although|always|am|an|and|any|are|as|at|be|became|become|but|by|can|could|did|do|does|each|either|else|for|from|had|has|have|hence|how|i|if|in|is|it|its|just|may|maybe|me|might|mine|must|my|neither|nor|not|of|oh|ok|when|where|whereas|wherever|whenever|whether|which|while|who|whom|whoever|whose|why|will|with|within|without|would|yes|yet|you|your)\b”,
“value”: “{{emptystring}}”,
“global”: true,
“sensitive”: false,
“multiline”: false,
“singleline”: false,
“text”: “this Without about test”
},
“metadata”: {
“designer”: {
“x”: 300,
“y”: 0,
“messages”: [
{
“category”: “last”,
“severity”: “warning”,
“message”: “A transformer should not be the last module in the route.”
}
]
},
“restore”: {
“expect”: {
“global”: {
“mode”: “chose”
},
“sensitive”: {
“mode”: “chose”
},
“multiline”: {
“mode”: “chose”
},
“singleline”: {
“mode”: “chose”
}
}
},
“expect”: [
{
“name”: “pattern”,
“type”: “text”,
“label”: “Pattern”,
“required”: true
},
{
“name”: “value”,
“type”: “text”,
“label”: “New value”
},
{
“name”: “global”,
“type”: “boolean”,
“label”: “Global match”,
“required”: true
},
{
“name”: “sensitive”,
“type”: “boolean”,
“label”: “Case sensitive”,
“required”: true
},
{
“name”: “multiline”,
“type”: “boolean”,
“label”: “Multiline”,
“required”: true
},
{
“name”: “singleline”,
“type”: “boolean”,
“label”: “Singleline”,
“required”: true
},
{
“name”: “text”,
“type”: “text”,
“label”: “Text”
}
]
}
}
]
}
],
“metadata”: {
“version”: 1
}
}

1 Like