Reputation: 12718
Given a line of text with two words, such as:
hi hello
How can I replace the first occurrence of a space with a comma, giving desired result:
hi, hello
Sublime text regex ^([^\s]*)(\s)
gives:
hi
hello
Where the gray represents the selected area (notice it's also including the word hi
, when it should only include the first space for replacing), which if I ran find replace on, would give:
, hello
Upvotes: 0
Views: 5796
Reputation: 10250
You capture up to the space and include the captured content in your replacement.
Find what: ^(\S*)\s
Replace with: \1,
Upvotes: 2