You don’t need a switch module, when a simple built-in if statement would work.
Here is the updated regex to exclude the dollar signs
<b>(?<type>Hourly Range|Budget)[^:]+:\s+\$(?<rate1>\d+(?:[.,]\d{2,3})*)(?:\s*-\s*\$(?<rate2>\d+(?:[.,]\d{2,3})*))?
Proof: https://regex101.com/r/9PBgx9
and here is the module export for you to paste into your scenario:
Module Export
You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.
-
Copy the JSON code below by clicking the copy button when you mouseover the top-right of the code block
-
Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the canvas.
-
Click on each imported module and save it for validation. You may be prompted to remap some variables and connections.
View Module Export Code
JSON
{
"subflows": [
{
"flow": [
{
"id": 125,
"module": "regexp:Parser",
"version": 1,
"parameters": {
"pattern": "<b>(?<type>Hourly Range|Budget)[^:]+:\\s+\\$(?<rate1>\\d+(?:[.,]\\d{2,3})*)(?:\\s*-\\s*\\$(?<rate2>\\d+(?:[.,]\\d{2,3})*))?",
"global": false,
"sensitive": true,
"multiline": false,
"singleline": false,
"continueWhenNoRes": false
},
"mapper": {
"text": "{{124.text}}"
},
"metadata": {
"designer": {
"x": -1810,
"y": -254
},
"restore": {},
"parameters": [
{
"name": "pattern",
"type": "text",
"label": "Pattern",
"required": true
},
{
"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": "continueWhenNoRes",
"type": "boolean",
"label": "Continue the execution of the route even if the module finds no matches",
"required": true
}
],
"expect": [
{
"name": "text",
"type": "text",
"label": "Text"
}
],
"interface": [
{
"type": "text",
"name": "type",
"label": "type"
},
{
"type": "text",
"name": "rate1",
"label": "rate1"
},
{
"type": "text",
"name": "rate2",
"label": "rate2"
}
]
}
},
{
"id": 128,
"module": "util:SetVariable2",
"version": 1,
"parameters": {},
"mapper": {
"name": "value",
"scope": "roundtrip",
"value": "{{if(125.type = \"Budget\"; 125.rate2; 125.rate1 + \"-\" + 125.rate2)}}"
},
"metadata": {
"designer": {
"x": -1564,
"y": -255
},
"restore": {
"expect": {
"scope": {
"label": "One cycle"
}
}
},
"expect": [
{
"name": "name",
"type": "text",
"label": "Variable name",
"required": true
},
{
"name": "scope",
"type": "select",
"label": "Variable lifetime",
"required": true,
"validate": {
"enum": [
"roundtrip",
"execution"
]
}
},
{
"name": "value",
"type": "any",
"label": "Variable value"
}
],
"interface": [
{
"name": "value",
"label": "value",
"type": "any"
}
]
}
}
]
}
],
"metadata": {
"version": 1
}
}
samliew – request private consultation
Join the Make Fans Discord server to chat with other makers!