Re: how to identify string between flower braces
- From: Bryan Oakley <oakley@xxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 27 Nov 2006 21:44:02 GMT
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?
.
- References:
- how to identify string between flower braces
- From: tampabay . bucks
- how to identify string between flower braces
- Prev by Date: Re: mysqltcl tips?
- Next by Date: Is there a way to make 'wish' read standard input?
- Previous by thread: how to identify string between flower braces
- Next by thread: Re: how to identify string between flower braces
- Index(es):
Relevant Pages
|