How to extract out the matched line of a txt file?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • markleo
    New Member
    • May 2022
    • 7

    How to extract out the matched line of a txt file?

    I have a special content txt file like this,



    Code:
    == desc.xxx >>>
    11111
    2222
    333
    == desc.xxx <<<
    4
    555
    666
    zzz
    == desc.yyy >>>
    rrr\
    == desc.yyy <<<
    ttt
    iii
    ppp
    ooo
    == desc.zzz >>>
    lll
    bbhhgfc
    
    == desc.zzz <<<

    my requirement is extract out the matched lines of the text. I want get the below result:
    Code:
    {
      "desc:xxx": {
        "start": 2,
        "end": 6
      },
      "desc.yyy": {
        "start": 11,
        "end": 13
      },
      "desc.zzz": {
        "start": 18,
        "end": 22
      },
      "undefined": [
        {
          "start": 1,
          "end": 1
        },
        {
          "start": 7,
          "end": 10
        },
        {
          "start": 14,
          "end": 17
        }
      ]
    }
    I searched google, but don't find a solution about this.
Working...