Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

268
Views
Skript - Get the body of the code component

I'm working on an extension for vs code that adds support for Skript syntax.

I'm stuck on that I can't select the body of the code block. In total, there are several of them in the Skript syntax (commands, functions, events, and a few more). Each block starts with a zero indent (it's indent sensitive). I have provided an example Skript syntax below.

on join:
    set the player's gamemode to spectator
    join_player(player)

command /join [<player>]:
    trigger:
        if arg-1 is not set:
            join_player(player)
        else:
            player has permission "op"
            join_player(arg-1)

function reset_arena():
    set all blocks within {loc1} and {loc2} to snow block

The original author of this extension used this construction. But it doesn't work with an odd number (\r\n|\r|\n). Also defines the last line of the document as not related to the last component.

if (search = component.match(/^(?<component>(command\s?(?<head>[^\:]*))\:?(.*)(?<body>((\r\n|\r|\n)([^a-zA-Z][^\r\n]*)?)*))/i)?.groups) {
    return this._createCommand(skDocument, range, search.component, search.head, search.body);  
}

Please tell me how to correctly make a regex so that the body of the component is selected. Thanks a lot

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I believe you need something like this:

(?<component>^\w+ +(?<head>.*)\n(?<body>(?:[\s\S](?!\n\w))*))

It will provide 3 groups for each match:

  1. component
  2. head
  3. body

You can have a better idea of how it works and make any modifications you may need in the following link: https://regex101.com/r/0VaKhR/2

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!