Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • OneLine replacement

    Hi Gurus,

    I was wondering if it is possible to insert { } to equalize the format, NOT using auxiliaries variables ( file is huge), but using just one line command (regex ?? ).

    Of course it must adjust only eligible cases with no { }.

    Code:
    clear
    input str67 var1
    `"{  "Department": "Corporate Systems",  "Project": "Project Alpha"} "'
    `""Department": "HR",  "Project": "Project Beta""'                     
    end
    
         +---------------------------------------------------------------------+
         |                                                                var1 |
         |---------------------------------------------------------------------|
      1. | {  "Department": "Corporate Systems",  "Project": "Project Alpha"}  |
      2. |                      "Department": "HR",  "Project": "Project Beta" |
         +---------------------------------------------------------------------+
    Desired Output:

    Code:
         +---------------------------------------------------------------------+
         |                                                                var1 |
         |---------------------------------------------------------------------|
      1. | {  "Department": "Corporate Systems",  "Project": "Project Alpha"}  |
      2. |                   { "Department": "HR",  "Project": "Project Beta"} |
         +---------------------------------------------------------------------+
    thks

  • #2
    I'm not sure I understand what you are doing here, but is it:
    Code:
    replace var1 = "{  " + var1 + "}" if substr(var1, 1, 1) != "{"

    Comment


    • #3
      thks, that is it!

      Comment

      Working...
      X