Sublime Forum

Regex: Caret not matching beginning of multiline selection

#1

I’m having trouble with a multi line regex. Say I have six lines of text. I want to quote the first word of lines 2-5 inclusive, deleting the rest of the line. I select those lines and enter the given regex.

When I do “Replace All” only lines 3-5 are changed, line 2 is unaffected.

The ^ character isn’t matching the beginning of the selected text, even though it follows a newline.

This is a common workflow for me. I’ll paste text from some other source, select the lines I just pasted, then perform some sort of transformation on each of those lines via find/replace. I just came back to ST after trying other editors for a while. I don’t recall ST3 working this way, nor did any of the other editors have this behavior. Is there some setting I might need to toggle somewhere? Or is it a bug? Please don’t tell me it’s working as designed!

Using ST4 stable, build 4126.

0 Likes

Regex ^ when selecting doesn't work in Sublime 4 but in Sublime 3 works
#2

Seems like this may be a bug. It only seems to manifest when a search is applied within a selection.

0 Likes

#3
0 Likes

#4

This seems like a real usability bug that should not have been sitting for a year :grimacing:. Here’s hoping the team will see this and fix it. Breaks like this in fundamental things like searching in a file are pretty important IMHO.

2 Likes

#5

Thanks for finding the issue in the tracker, I wasn’t sure where to look. Yes, that’s exactly what I’m seeing.

0 Likes

#6

Maby this help for you plugin RegReplace

0 Likes