Understanding regexp in atom?


#1

Hello,

I am trying to understand how the regexp in search and replace work for atom.io however there are a few things that catches my eyes as wrong or missleading so there for this topic.

In most editors I have used $ to mark the end of line and append something. This however does not work in atom. Anyone knows what the equivalent is?

Also ^ is what I have used for the beginning of line to append in the beginning. But that also does not do what I expect.

Is there any instructions or documentation of how the regexp is build for atom?

Thank you


#2

Did you activate the Use regexp option in the search view?

Because, as far as I can tell, it works as expected once activated:


#3

Hello,

Thanks for your reply. However thats not really what I mean. Yes regexp is enabled.

However that regexp you are using is saying (beginning of line and .) I am just looking for the definite beginning of line:

^ Matches the starting position within the string. In line-based tools, it matches the starting position of any line.
$ Matches the ending position of the string or the position just before a string-ending newline. In line-based tools, it matches the ending position of any line.

So the search would be:

Find: ^
Replace: test

And that should add the text “test” to the beginning of line which it does not do at the moment.

So it does not really do what is expected.


#4

What you are encountering is a known problem; ^ and $ are not supported by find-and-replace. The multiline regex support in fnr is a bit lacking as of right now.


#5

Oh sorry, I didn’t understand you were talking about ^ and $ as the only search term.


#6

Thank you that actually answers a lot. Hope that it will be solved soon enough


#7

You can use
find: \n
replace: \ntest or test\n
to prepend or append test to each line except the first or last, respectively.