Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Intellij regex to find and replace

I need below text to be find by using regex in Intellij

messageSource.getMessage("error1.test1",null, null)
messageSource.getMessage("error2.test2",null, null)
messageSource.getMessage("error3.test3",null, null)
messageSource.getMessage("error4.test4",null, null)
messageSource.getMessage("success",null, null)
messageSource.getMessage("error",null, null)

I need this to replace with below

messageSource.getMessage("error1.test1",null, Locale.ENGLISH)
messageSource.getMessage("error2.test2",null, Locale.ENGLISH)
messageSource.getMessage("error3.test3",null, Locale.ENGLISH)
messageSource.getMessage("error4.test4",null, Locale.ENGLISH)
messageSource.getMessage("success",null, Locale.ENGLISH)
messageSource.getMessage("error",null, Locale.ENGLISH)

Note: These are just some examples, but hundres of lines are there across the project. error1.test1, success these texts can be with . (dot) or without dot , no numerics involved (only alphabets)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I tired to some extend, but couldn’t finish exactly
messageSource.getMessage\(\"[a-zA-Z]*.[a-zA-Z]*",[null]*,[null]*

>Solution :

You may try the following find and replace, in regex mode:

Find:    messageSource.getMessage\(\s*(\S+?)\s*,\s*null\s*,\s*null\s*\)
Replace: messageSource.getMessage($1, null, Locale.ENGLISH)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading