首页 \ 问答 \ 在语法定义中表示Sublime Text正则表达式中的“小于”符号(Represent “less-than” symbol in Sublime Text regex in syntax definition)

在语法定义中表示Sublime Text正则表达式中的“小于”符号(Represent “less-than” symbol in Sublime Text regex in syntax definition)

我正在使用一个古老的前XML标记,它使用“$ = x”形式的代码,其中x可以是字母字符或键盘上的符号,例如; (分号),? (问号)或<左角括号,又 大于 小于)。 [编辑后的注意事项:原始措辞中出现的混淆问题是问题的核心所在。 请参阅我对已接受答案的评论。 RS]

所以我在我的User文件夹中修改了XML.tmLanguage语法定义文件的副本,以识别这些代码所代表的11个不同的类别,因此我可以在大文本文件(也包含XML标记)中轻松看到它们我是与...合作。

对于所有符号,除了<我能够通过在其前面加上反斜杠来转义符号。 但是在ST2使用的Boost正则表达式引擎中, \<是表示您只想在单词的开头匹配的方式。 因此,我无法正确识别和突出显示此代码。

在这种情况下,我到处寻找如何逃避<符号。 我试过用0,1,2,3和4反斜杠前面的; 我也尝试使用十六进制转义码\x{3009} 。 [注意:这是大于而不是小于的代码。]

一切都是徒劳。 (一些替代方案没有生成错误消息,但也没有突出显示代码。)

因为我正在处理的代码需要以不同的颜色着色,所以我不能使用通用符号代替< ,我也不能指定它。 我怎么得到这个?


I'm working with an ancient pre-XML markup that uses codes of the form "$=x", where x may be an alphabetic character or a symbol on the keyboard, such as ; (semicolon), ? (question mark), or < ( right left angle bracket, aka greater-than less-than). [Note after editing: the confusion manifested in the question as originally phrased goes to the heart of the problem. See my comment to the accepted answer. RS]

So I've modified a copy of XML.tmLanguage syntax definition file in my User folder to identify the eleven different categories that these codes represent, so I can easily see them in the large text files (which also contain XML markup) I'm working with.

For all the symbols except < I'm able to escape the symbol by preceding it with a backslash. But in the Boost regex engine that ST2 uses, \< is how you indicate that you want to match only at the start of a word. Consequently I've been unable to get this code to be properly recognized and highlighted.

I've looked everywhere for how to escape the < symbol in this circumstance. I've tried preceding it with 0, 1, 2, 3 and 4 back-slashes; and I also tried using the hexadecimal escape code \x{3009}. [Note: this is the code for greater-than instead of less-than.]

All in vain. (A few alternatives didn't generate an error message but also didn't highlight the code.)

Because the codes I'm working with need to be colored differently, I can't use a generic symbol in lieu of <, and I can't specify it either. How do I get this?


原文:https://stackoverflow.com/questions/19571749
更新时间:2022-06-26 13:06

最满意答案

我已经编辑了代码现在正在工作。 你应该把两个输入放在两个不同的观察中。

这是服务器。 R:

server <- function(input, output, session){

  fund_group <- reactive({ # this is the list of fund group including fund name
    # for example,
    list("domestic" = c("a","b", "c"),  "global" = c( "aa", "bb", "cc"))
    # list name and fund name in the list are changable
  })

  observe({
    group_name <- reactive({ names(fund_group()) })
    updateSelectInput( session,
                       "select_group",
                       choices = group_name() )

  })

  observe({
    fund_list <- reactive({ fund_group()[[input$select_group]] })
    updateCheckboxGroupInput( session,
                              "fund_in_group",
                              choices = fund_list(),
                              selected = fund_list())
  })

}

这是ui.R:

ui <- navbarPage( "narvarTitle",
            tabPanel( "tab panel",

                      fluidRow( column( 3, wellPanel( textOutput( "fixed_anual_date" ),
                                                      br(),
                                                      br(),
                                                      selectInput( "select_group",
                                                                   label = "Select group",
                                                                   choices = "" ),
                                                      br(),
                                                      checkboxGroupInput( "fund_in_group",
                                                                          label = "Select funds :",
                                                                          choices = "" ),
                                                      br()
                      ) )
                      ) )

)

[编辑]:

根据您的最新更新,我修改了服务器代码,以便在dataset更改时更新checkboxGrouptInput并为已检查的列呈现表。

shinyServer( function(input, output, session) {

  dataset_list <- list( "rock" = rock,    
                        "pressure" = pressure,
                        "cars" = cars
  )

  observeEvent( input$n_select_input, {

    selected_dataset <- reactive({ 
      selected_list <- list()
      for( i in 1:input$n_select_input ){
        selected_list[[i]] <- dataset_list[[i]]
      }

      names(selected_list) <- names( dataset_list )[1:input$n_select_input]
      selected_list
    })


    colname_indata_list <- reactive({

      colname.indata.list <- list()
      for( set in names( selected_dataset() ) ){
        colname.indata.list[[set]] <- colnames( selected_dataset()[[set]] )
      }

      colname.indata.list
    })


    choice_cand <- reactive({ 
      names(selected_dataset()) })

    updateSelectInput( session,
                       "dataset",
                       choices = as.character( choice_cand() )
    )

    ######################################Start: Modified#############################

    observe({

      input$dataset  ##Added so that this observe is called when the input$dataset changes
      choices_cand <- reactive({ 

        colname_indata_list()[[input$dataset]] })

      updateCheckboxGroupInput( session, 
                                "column",
                                choices = as.character( choices_cand()) ,
                                selected = as.character( choices_cand())
      )

    })

    })

  ######################################End: Modified#############################


  datasetInput <- reactive({
    switch(input$dataset,
           "rock" = rock,
           "pressure" = pressure,
           "cars" = cars)
  })

  output$table <- renderTable({
    datasetInput()[,input$column]##only selected columns are displayed
  })


} ) 

希望这可以帮助!


I have edited the code an its working now. You should put the two input in two different observe.

Here is the server. R:

server <- function(input, output, session){

  fund_group <- reactive({ # this is the list of fund group including fund name
    # for example,
    list("domestic" = c("a","b", "c"),  "global" = c( "aa", "bb", "cc"))
    # list name and fund name in the list are changable
  })

  observe({
    group_name <- reactive({ names(fund_group()) })
    updateSelectInput( session,
                       "select_group",
                       choices = group_name() )

  })

  observe({
    fund_list <- reactive({ fund_group()[[input$select_group]] })
    updateCheckboxGroupInput( session,
                              "fund_in_group",
                              choices = fund_list(),
                              selected = fund_list())
  })

}

Here is the ui.R:

ui <- navbarPage( "narvarTitle",
            tabPanel( "tab panel",

                      fluidRow( column( 3, wellPanel( textOutput( "fixed_anual_date" ),
                                                      br(),
                                                      br(),
                                                      selectInput( "select_group",
                                                                   label = "Select group",
                                                                   choices = "" ),
                                                      br(),
                                                      checkboxGroupInput( "fund_in_group",
                                                                          label = "Select funds :",
                                                                          choices = "" ),
                                                      br()
                      ) )
                      ) )

)

[EDIT]:

As per your latest update I have modified the server code so that checkboxGrouptInput is updated as dataset changes and also the table is rendered for the checked columns.

shinyServer( function(input, output, session) {

  dataset_list <- list( "rock" = rock,    
                        "pressure" = pressure,
                        "cars" = cars
  )

  observeEvent( input$n_select_input, {

    selected_dataset <- reactive({ 
      selected_list <- list()
      for( i in 1:input$n_select_input ){
        selected_list[[i]] <- dataset_list[[i]]
      }

      names(selected_list) <- names( dataset_list )[1:input$n_select_input]
      selected_list
    })


    colname_indata_list <- reactive({

      colname.indata.list <- list()
      for( set in names( selected_dataset() ) ){
        colname.indata.list[[set]] <- colnames( selected_dataset()[[set]] )
      }

      colname.indata.list
    })


    choice_cand <- reactive({ 
      names(selected_dataset()) })

    updateSelectInput( session,
                       "dataset",
                       choices = as.character( choice_cand() )
    )

    ######################################Start: Modified#############################

    observe({

      input$dataset  ##Added so that this observe is called when the input$dataset changes
      choices_cand <- reactive({ 

        colname_indata_list()[[input$dataset]] })

      updateCheckboxGroupInput( session, 
                                "column",
                                choices = as.character( choices_cand()) ,
                                selected = as.character( choices_cand())
      )

    })

    })

  ######################################End: Modified#############################


  datasetInput <- reactive({
    switch(input$dataset,
           "rock" = rock,
           "pressure" = pressure,
           "cars" = cars)
  })

  output$table <- renderTable({
    datasetInput()[,input$column]##only selected columns are displayed
  })


} ) 

Hope this helps!

相关问答

更多

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)