Search code examples
variablesvariable-assignmentautoitbulk

How to convert text lines to variables?


Check out this list. I need each one turned into a variable and set equal to 0. Example:

;1-Methyoxy-2-Propanol would be:
$OneMethoxyTwoPropanol = 0

;and 1,2-BUTADIENE would be:
$OneTwoButadiene = 0

Assigning them to a variable wouldn't be a problem, but there are 1500 of them.


Solution

  • If i had to do this work i'll make it this way :

    • I'll change the case of each word :

    Regex to change to sentence case

    • Make a "SearchAndReplace" :

      1 -> One

      2 -> Two

      ...

      {underscore} -> ''

      {space} -> ''

      ...

    • Then in a soft like SublimeText i'll add a $ in front of each line and a = 0 at the end. With the help of the Ctrl+Shift+L

    Maybe you could use a regex to help you in the "SearchAndReplace" thing.