0

I wanted to replace text based on 1 digit code all at once

08-m

08-o

into

08_may

08_october

what I am trying to do is replace "m" into "may","o" into "October" all these at once,I am trying to put them in conditional replacement in atom editor

capturing using 08-(\w)

replacing expression 08-(?(\w="m")may|?(\w="o")october)

its not working and I dont know why

I am a beginner in regex,not finding what I am looking for anywhere,pardon me if you find it really dumb.Thanks.

  • You cannot use regex in replacement patterns. To replace with different values, you can only use Notepad++. – Wiktor Stribiżew Jul 31 '18 at 09:14
  • @WiktorStribiżew as a vim user, disagree your "you can only use Notepad++" comment. ^_^ – Kent Jul 31 '18 at 09:16
  • @Kent Ok, [Vim](https://stackoverflow.com/q/17337979/3832970) and [Notepad++](https://stackoverflow.com/a/37161309/3832970). Though in Vim, it looks like a whole separate language already. – Wiktor Stribiżew Jul 31 '18 at 09:19
  • @WiktorStribiżew yes vim regex has some difference from PCRE, however IMO, in some cases, it is more powerful than PCRE. – Kent Jul 31 '18 at 09:24
  • @Kent I would not compare it to PCRE, they are rather different. If you ask me, I'd call Vim regex a "language isolate". Ah, and if you mentioned PCRE because I mentioned Notepad++, just FYI that NPP uses Boost regex library, not PCRE. – Wiktor Stribiżew Jul 31 '18 at 09:28

1 Answers1

0

did you try Find in Project?

Use shortcutctrl+shift+f then complete Find in project with 08-m and Replace in project with 08_may. Complete the File/directory input then click on Replace All.

Do the same for 08-o and do not hesitate to first click on Find All to be sure not to make mistakes.

This is not really a regex answer but can be usefull if your aim is the solution and not the method.

Community
  • 1
  • 1
v-gael
  • 126
  • 9