-1

I have translation files like bellow

THANK_YOU               =   Thanks for contacting us! We’ll get back to you as soon as possible.
Name                    =   Name
First                   =   First
Last                    =   Last
Email                   =   Email
Your Comments           =   Your Comments
Submit                  =   Submit

Now I need to change the format like this

'THANK_YOU'               =>   'Thanks for contacting us! We’ll get back to you as soon as possible.',
'Name'                    =>   'Name',
'First'                   =>   'First',
'Last'                    =>   'Last',
'Email'                   =>   'Email',
'Your Comments'           =>   'Your Comments',
'Submit'                  =>   'Submit'

And don't know which regex to use in Notepad++ for the result I need. Or there is a better solution or editor.

  • Looks like you are looking to create a regex, but do not know where to get started. Please check [Reference - What does this regex mean](https://stackoverflow.com/questions/22937618) resource, it has plenty of hints. Also, refer to [Learning Regular Expressions](https://stackoverflow.com/questions/4736) post for some basic regex info. Once you get some expression ready and still have issues with the solution, please edit the question with the latest details and we'll be glad to help you fix the problem. – Wiktor Stribiżew Apr 02 '20 at 23:08
  • Thanks, I have found a solution. First I replaced new lines with new lines including quotes and comma using `\r\n` -> `',\r\n'` then `\s+=\s+` -> `' => '` – Takhtak Team Apr 02 '20 at 23:40

1 Answers1

0
  • Ctrl+H
  • Find what: ^(.+?)(\h+=)(\h+)(.+)$
  • Replace with: "$1"$2>$3"$4"
  • CHECK Wrap around
  • CHECK Regular expression
  • UNCHECK . matches newline
  • Replace all

Explanation:

^               # beginning of line
  (.+?)         # group 1, 1 or more any character but newlines, the text before equal sign
  (\h+=)        # group 2, 1 or more horizontal spaces and equal sign
  (\h+)         # group 3, 1 or more horizontal spaces
  (.+)          # group 4, the text after the equal sign
$

Replacement:

"$1"            # content of group 1 surround by quotes
$2              # content of group 2
>               # literally >
$3              # content of group 3
"$4"            # content of group 4 surround by quotes

Screenshot (before):

enter image description here

Screenshot (after):

enter image description here

Toto
  • 83,193
  • 59
  • 77
  • 109