[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: String Index
From: |
PhilipNienhuis |
Subject: |
Re: String Index |
Date: |
Sun, 26 Jun 2016 21:56:50 -0700 (PDT) |
Thomas D. Dean-2 wrote
> I have a string, 87 characters. containing pairs of parens enclosing
> characters. The number of chars enclosed is not constant. There are 2
> to 5 pairs of parens. How do I construct the index to vectorize this?
>
> > n=numel(str)
> n = 87
> > lp = [1:n](str == "(");
> > rp = [1:n](str == ")");
> > ## check to see if parens paired and lp < rp
> > [lp', rp']
> ans =
> 38 47
> 54 57
> 66 73
> 85 87
>
> I want to extract values from str using lp and rp
>
> > [ str(lp(1):rp(1));
> > str(lp(2):rp(2));
> > str(lp(3):rp(3));
> > str(lp(4):rp(4)) ]
> ans =
> (10^20 kg)
> (km)
> (kg/m^3)
> (1)
Read up on regexp()
Philip
--
View this message in context:
http://octave.1599824.n4.nabble.com/String-Index-tp4678013p4678014.html
Sent from the Octave - General mailing list archive at Nabble.com.