Skip to main content
Make the question title match the question asked in the body
Link

How do I matchreplace only the first space on a line?

Added an example.
Source Link

I'm trying to use M-x replace-regex to find and replace the first space on each line. What regex would I use to do this?

Everything I've tried either finds no matches or every space.

The lines never start with a space.

As an example, if my line consisted of What did the fox say? I would like to replace the space between What and did. I would not like to match the What.

I'm trying to use M-x replace-regex to find and replace the first space on each line. What regex would I use to do this?

Everything I've tried either finds no matches or every space.

I'm trying to use M-x replace-regex to find and replace the first space on each line. What regex would I use to do this?

Everything I've tried either finds no matches or every space.

The lines never start with a space.

As an example, if my line consisted of What did the fox say? I would like to replace the space between What and did. I would not like to match the What.

Source Link

How do I match only the first space on a line?

I'm trying to use M-x replace-regex to find and replace the first space on each line. What regex would I use to do this?

Everything I've tried either finds no matches or every space.