Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sd fails to match when using ^ to delimit the beginning of the line #60

Closed
Porkepix opened this issue Jan 10, 2020 · 3 comments
Closed

Comments

@Porkepix
Copy link

When trying some search & replace where I wanted to match something only if the line was starting with it, I wanted to use the usual ^ to flag the beginning of the line. The result was a fail of the match wail getting rid of it resulted in fine matching.
I tried to escaping it, guessing that as $ is used for variables, it probably needs some escaping to flag the end of a line the same way, but this didn't work as well.

I guess that ^and $ should somehow be usable to flag beginning and end of the line.

@Gutem
Copy link

Gutem commented Jan 21, 2020

Yep. My sed regex to match HTML Tags <[^>]*> doesn't work.

@seebye
Copy link

seebye commented Jan 23, 2020

I ran into the same issue.
Also I noticed that it works as expected on the first line,
so I enabled the multiline flag and it worked as expected afterwards.
E.g. shell history without line numbers:

history | sd -f m '^\s*[0-9]+\s+' '' | less

@chmln
Copy link
Owner

chmln commented Jan 25, 2020

Thanks for reporting this @Porkepix. I also believe the multi-line flag makes more sense to have as a default, similar to sed.

@chmln chmln closed this as completed in 87491b4 Jan 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants