Loading ...
Sorry, an error occurred while loading the content.

Searching variables with regex?

Expand Messages
  • Paul
    Hi, Who s up for a challenge? (HELLLLLPPPPPP!!!) I d like to search a text file for curly delimited brackets, that may also be nested. I would then like to
    Message 1 of 35 , Oct 3, 2010
    • 0 Attachment
      Hi,
      Who's up for a challenge? (HELLLLLPPPPPP!!!)

      I'd like to search a text file for curly delimited brackets, that may also be nested. I would then like to save the contents within the brackets to a variable and subsequently run a routine on the variable, searching preferably using regex code.

      Is this possible within NTP or do I need to resort to Perl for something this complex?

      e.g. {term one|term two} or {term A{term B|term C}}
      A simple ^!Find using the R switch gets the innermost bracketed term. My :LabeledSubroutine can then work out which term, term B or term C, to use and 'pass it back' somehow. Then the :LabeledSubroutine should get a variable "term A term B" or "term A term C" depending on the subroutine algorithm.

      Alternatively the :LabeledSubroutine could be designed to process the entire nest of search terms first by numbering the terms $1, $2, etc. and then have some sensibility about where the nesting occurs.

      Before I delve into hard coding - i've written the basic pseudocode - and it looks like I may have to resort to a dedicated programming language. However, my gut feeling is that NTP can probably do this.

      A couple of pointers to commands and functions to tackle this would be helpful or a simple 'go learn Perl' if that's best.

      Thanks in advance.
      Paul
    • Paul
      See? There s always someone ready to apply the rules even when I thought I was doing something harmless?!! sry bout that.. point taken. will visit
      Message 35 of 35 , Oct 11, 2010
      • 0 Attachment
        See? There's always someone ready to apply the rules even when I thought I was doing something harmless?!! <ahem> sry 'bout that.. point taken. will visit over there.....

        --- In ntb-clips@yahoogroups.com, Axel Berger <Axel-Berger@...> wrote:
        >
        > Paul wrote:
        > > I only stiffly object to copied work when it is purported to be
        > > ones own work. In the early stages of professional development
        > > I advocate reprimand and retraining.
        >
        > This is beginning to drift off the topic od clips, My answer certainly
        > is, which is why I just posted it to the off-topic list.
        >
        > Axel
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.