No3371 / obsidian-regex-pipeline

An Obsidian plugin that allows users to setup custom regex rules to automatically format notes.
70 stars 8 forks source link

New line character in the replacement side #15

Closed beniza closed 2 years ago

beniza commented 2 years ago

Could you please provide a sample that has inserts a new line (\n) character on the replacement side. For example if I want to split a timestamp 01:30 to

01
30

how do I do it?

I tried the following, but didn't work:

  "(\d{2}:\d{2})"->"$1\n$2"
  "(\d{2}:\d{2})"->"$1\r\n$2"
  "(\d{2}:\d{2})"->"$1`\n`$2"
beniza commented 2 years ago

Never mind... I found the workaround

I used \<br> tag to insert a new line.

No3371 commented 2 years ago

It's pretty plain: "(\d{2}:\d{2})"->"$1 $2"

beniza commented 2 years ago

It's plain, but not really the regex way. So it might help you give some explicit information/documentation. Anyways, I'm very grateful for the plugin. So a big thanks to you!

No3371 commented 2 years ago

Not trying to argue but I'd like to clarify this is included in the readme.

And thanks for the kind words! By the way 1.3 was released just not long ago, get a update and enjoy😄

howardpy commented 1 year ago

Hi, a bit new here with regex, this is a great plugin. Why is it not "(\d{2}):(\d{2})" ->"$1\n$2"? That may also help me understand why I can get Regex Find/Replace plugin to work but have no success with Regex Pipeline to delete [[ and ]] in linked file lists.

No3371 commented 1 year ago

Your regex is not wrong at all. To be honest this is Regex Pipeline not doing enough to follow the convention. To handle escaped character like \n, the plugin must be able to properly recognize \ and \\ (allow escaping slashes) , and for now I personally have no motivation to add it when it's already working for me.

beniza commented 1 year ago

Oh yeah! It was already there. That was my mistake. I somehow couldn't see it because I was looking for \ns on the right side as well.

On Thu, 1 Sept 2022 at 20:26, BA @.***> wrote:

Not trying to argue but I'd like to clarify this is included in the readme https://github.com/No3371/obsidian-regex-pipeline#multi-line-replacement-string .

And thanks for the kind words! By the way 1.3 was released just not long ago, get a update and enjoy😄

— Reply to this email directly, view it on GitHub https://github.com/No3371/obsidian-regex-pipeline/issues/15#issuecomment-1234397710, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABFOPKZ5SVPP3AKKTJFKGG3V4C72JANCNFSM6AAAAAAQCHFICU . You are receiving this because you modified the open/close state.Message ID: @.***>