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

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

RTILA X PROJECT 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": "extract_regex",
              "pattern": "\\$([\\d,]+)",
              "group": 1,
              "flags": "",
              "default_value": ""
            }
          ]
        },
        {
          "name": "salary_max",
          "type": "text",
          "selector": "css=td:nth-child(3)",
          "transformations": [
            {
              "type": "extract_regex",
              "pattern": "\\$([\\d,]+)$",
              "group": 1,
              "flags": "",
              "default_value": ""
            }
          ]
        }
      ]
    }
  },
  "commands": [
    {
      "command": "wait_for_selector",
      "params": {
        "selector": "css=table.salary-table"
      }
    },
    {
      "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?