Re: how to identify string between flower braces



tampabay.bucks@xxxxxxxxx wrote:
Hi

I have a string which would be something like below :

set myStr "{8} {Security Configuration} {null} {}} {{9}"

I would to retrieve what is present inside the flower braces after
Security Configuration which is "null" in this case. Can i do this with
a regular expression ?

FWIW, "flower braces" are typically called "curly braces" or just "braces" in this newsgroup.

Assuming the above is an accurate representation of your whole data, you indeed must use something like regexp. If it were a tcl list (such as returned by an sqlite query, for example) you could simply use lindex.

If you know your data is not a list you must use string commands. This might do the trick:

regexp {{.*?}\s+{.*?}\s{(.*?)}} -- $myStr answer

This will only work for a very specific pattern though. Specifically, a matched set of braces, some whitespace, another matched set of braces, some whitespace, then whatever is in the third matched set of braces.

Is there a chance your data is actually a list that you mistyped, or is it really a string with mismatched braces?

.



Relevant Pages

  • Re: Luthier question: Intonating via thinning braces
    ... Is it possible, in your experience, to alter the intonation of one ... string by thinning the braces, whether one brace or more than one. ... Do you recall if your tweaked guitar had a change in intonation? ...
    (rec.music.classical.guitar)
  • Re: empty list
    ... Dan Smart wrote: ... string, and that strings can be converted to lists, and as previously ... stated I'd be very happy if braces actually constructed lists. ...
    (comp.lang.tcl)
  • Re: Curly braces and the logic of PERL
    ... even though an equal number of left & right braces ... much Perl Golf;) The objective of Perl Golf is to write a program to ... # $string is a global containing the string to look for; ... # $REPORT is a global file handle to the output file; ...
    (perl.beginners)
  • Re: Parsing Strings in Enclosed in Curly Braces
    ... x = "{ABC EFG IJK LMN OPQ}" ... Can you have braces legitmately lying around in the string, ... Can you have nested braces, and what are you supposed to do with them: ... Parsing is not an entirely trivial subject, ...
    (comp.lang.python)
  • Re: Dynamic column specification in table update
    ... you need braces to EXEC a string. ... Tibor Karaszi, SQL Server MVP ...
    (microsoft.public.sqlserver.programming)