Sublime Forum

Regex select first space in a line

#1

I want to select the first occurrence of a space in a line to change that positional character. Each line can have numerous spaces. I’ve search the web trying several variations and have taken a short regex course online. I cannot seem to get it right. Any help is appreciated.
Sample text:

`xxxxxxxxxxxxxxxxxxx                                                  
`xxxxxxxxxxxxxxxxxx                                                 
`xxxxxxxxxxxxxxxxx                                                   
`xxxxxxxxxxxxxxxxxxXxxx                                              
`xxxxxxxxxxxxxxxXxxxx                                                
`xxxxxxxxxxxxxxxxxXxxxx                                              
`xxxxxxxxxxxxxxx                                                     
`xxxxxxxxxxxxxxxxxxxXxxxxxxxxxXxxx                                   
`xxxxxxxxxxxxxxxxxxxXxxxxxxxxxXxxxxxx                                
`xxxxxxxxxxxxxxxxxxxxxxxxxxxxXxxx                                    
`xxxxxxxxxxxxxxxxxxxxxxxxxxXxxxxxxxxXxxxxxxXxxXxxxx                  
`xxxxxxxxxxxxxxxxxxxxxxxxxxXxxxxxxxxXxxxxxxXxxXxxxx                  
`xxxxxxxxxxxxxxxxxxxxxxxxxxXxxxxxxXxxxxxxxXxxxxxxXxxxXxxxXxxxx       
`xxxxxxxxxxxxxxxxxxxxXxXxxxxxxXxxXxxxx                               
`xxxxxxxxxxxxxxxxxxxxxxxxxxXxXxxxxxxXxxxXxxxXxxxx                    
`xxxxxxxxxxxxxxxx                                                    
`xxxxxxxxxxxxxxxxXxxxxxxx
0 Likes

#2

You can use ^[^\s]+ to put cursors at positions right at first spaces.

0 Likes

#3

Hmmmm, that’s not working for me.
That selected all of the characters

I’m attempting to use regex in sublime

The forum is not letting me key show the back-tick so I’ll use the word backTick
backTick = `

\S\s
selects the last character and the first space - that’s almost what I want

`xxxxxxxxxxxxxxxxx+backTick+Space

trying to replace the first space with a backTick
`xxxxxxxxxxxxxxxxxbackTick

so that it’s quoted in backTick marks

0 Likes

#4

0 Likes

#5

Oh thanks so much!!! That works for what I’m trying to do.

0 Likes