Skip to main content

data-transformation Scenario 2 — Extract Salary with Regex and Export JSON

Written by RTILA X Engineering Team

Beginner ~4 min

What You'll Learn

Extract salary figures with regex

Real-World Use Case

Parsing job board listings

LIVE DEMO

Salary Regex Parsing

Salary ranges split into numeric minimum and maximum values.

Job TitleCompanySalary Range
Senior Developer TechCore $85,000 - $120,000
Product Designer PixelWorks $70,000 - $95,000
Data Analyst Insight Lab $90,000 - $130,000
Support Specialist HelpDesk $60,000 - $80,000
Engineering Manager BuildFlow $100,000 - $150,000
Content Strategist StoryFirst $75,000 - $110,000
EXPECTED OUTPUT

Salaries

title company salary_min salary_max
Senior Developer TechCore 85000 120000
Product Designer PixelWorks 70000 95000
Data Analyst Insight Lab 90000 130000
Support Specialist HelpDesk 60000 80000
Engineering Manager BuildFlow 100000 150000
Content Strategist StoryFirst 75000 110000
RTILA X PROJECT JSON

RTILA X Automation Project

extract-salary-regex.json
{
  "name": "Extract_Salary_With_Regex",
  "settings": {
    "urls": [
      "https://learn.rtila.com/scenarios/data-transformation/2"
    ]
  },
  "datasets": {
    "salaries": {
      "item_selector": "css=table.salary-table tbody tr",
      "properties": [
        {
          "name": "title",
          "type": "text",
          "selector": "css=td:nth-child(1)"
        },
        {
          "name": "company",
          "type": "text",
          "selector": "css=td:nth-child(2)"
        },
        {
          "name": "salary_min",
          "type": "text",
          "selector": "css=td:nth-child(3)",
          "transformations": [
            {
              "type": "script",
              "code": "const match = String(value).match(/\\$([\\d,]+)/); return match ? parseInt(match[1].replace(/,/g, ''), 10) : 0;",
              "default_value": 0
            }
          ]
        },
        {
          "name": "salary_max",
          "type": "text",
          "selector": "css=td:nth-child(3)",
          "transformations": [
            {
              "type": "script",
              "code": "const match = String(value).match(/\\$[\\d,]+\\s*-\\s*\\$([\\d,]+)/); return match ? parseInt(match[1].replace(/,/g, ''), 10) : 0;",
              "default_value": 0
            }
          ]
        }
      ]
    }
  },
  "commands": [
    {
      "command": "extract_data",
      "params": {
        "dataset": "salaries"
      }
    },
    {
      "command": "comment",
      "params": {
        "text": "Use JSON export trigger after extraction"
      }
    }
  ]
}

The extract_regex transformation reads a salary range string and pulls the first and last dollar amounts into separate numeric fields.

Did you complete this scenario?

Ready to run this automation?

Copy the project JSON above, open RTILA X, create a new project, and paste it.

This scenario covers 2 RTILA X commands and is referenced in 2 learning articles.

Continue Learning

Was this helpful?