Skip to main content

Splitting and Extracting

When a column contains multiple pieces of information (like "first last" or "user@domain.com"), use these commands to split it into separate columns. All three are non-destructive — the original column stays untouched.

Learning Focus

Use : to split by a delimiter (space, comma, dot). Use ; to extract named parts with capture groups. Use * to create a regex-replaced copy as a new column.

Quick Comparison

CommandWhat it doesBest for
: regexSplit by delimiter"John Smith"first, last
; regexExtract capture groups"user@domain.com"user, domain
* s<Tab>rRegex replace as new columnStrip/transform values non-destructively

Regex Split (:)

Split a single column into multiple columns by a regex delimiter. New columns are named original_1, original_2, etc.

: regex # split current column into sub-columns by regex pattern
# Move to 'full_name' column
:
# Enter: \s+
# Creates: full_name_1, full_name_2

# Move to 'ip_address' column
:
# Enter: \.
# Creates: ip_1, ip_2, ip_3, ip_4

# Move to 'log_entry' column
:
# Enter: \|
# Creates: log_entry_1, log_entry_2, ...

Capture Group Extraction (;)

Extract named or numbered regex capture groups as new columns. With named groups, the column names match the group names.

; regex # extract capture groups from current column as new columns
# Extract username and domain from email
# Move to 'email' column
;
# Enter: (?P<user>[^@]+)@(?P<domain>.+)
# Creates: user, domain

# Extract fields from a log line
;
# Enter: (?P<ip>\S+) \[(?P<date>[^\]]+)\] "(?P<method>\w+) (?P<path>\S+) (?P<code>\d+)"
# Creates: ip, date, method, path, code

Regex Replace as New Column (*)

Create a new column by applying a regex replacement — the original column is preserved.

* search<Tab>replace # create new column with regex replacement
# Strip port from endpoint URLs
# Move to 'endpoint' column
*
# Enter: :\d+<Tab>
# Creates: endpoint_2 (without port number)

# Normalize status: "active" → "ACTIVE"
*
# Enter: active<Tab>ACTIVE
# Creates: status_2 (with normalized values)

For in-place regex replacement on existing columns (g*, gz*), see Column Editing.


Quick Reference

KeyActionPython?Result
: regexSplit by delimiterNoMultiple new columns
; regexExtract capture groupsNoMultiple named new columns
* s<Tab>rRegex replace (new column)NoNew column, original preserved

Hands-On Practice

vd ~/github/practice-folder/visidata/01-loading/01-employees.csv

# 1. Move to 'email' column
# 2. Press ; → (?P<user>[^@]+)@(?P<domain>.+) → creates user, domain columns
# 3. Press = → user + '@' + domain → same_email → verifies extraction

What's Next