[ncl-talk] Possible bug or improvement for the function "str_index_of_substr"

Yuqiang Zhang yuqiangzhang.thu at gmail.com
Fri Dec 9 17:35:30 MST 2016


Hi Dennis,

That does makes sense. Thanks for the quick function!

I do have another small question: I always want to know if Idx = 0 already,
how to make the idx = (/0, 4/). I know there is an append function, but
that only works if idx is a two dimension array.

Thanks!

Regards,
Yuqiang

On Fri, Dec 9, 2016 at 4:55 PM Dennis Shea <shea at ucar.edu> wrote:

> This would require 'recursive' searching.... letter-by-letter
>
> ABAABA , ..... NC=7  (# characters)
> 0123456
>
> [0[ set 'idx=0'
> [1] Find 'ABA', success;  IDX = 0
> [2] set 'idx=1', and search the string   BAABA
> [3] Find 'ABA', success, set IDX = (/0,4/)
> [4] set idx=5
> [5] repeat .... ad infinitum
>
> I think you could write a function that does that.
>
> undef("get_many_index_str")
> function get_many_index_str(str:string)
> begin
>   ...
>     return(IDX)
> end
>
> Why does NCL not do that? Well, let's say NC=1000000
> This would be VERY time consuming.
>
>
> On Fri, Dec 9, 2016 at 2:31 PM, Yuqiang Zhang <yuqiangzhang.thu at gmail.com>
> wrote:
>
> Hi Dear NCL developers,
>
> I was using the "str_index_of_substr" to find the sub array recently, and
> found some interesting thing about it.
>
> For example,
>
> a = "ABABA"
> substr = "ABA"
>
> i1 = str_index_of_substr(a, substr, 0)
> print(i1)
>
> The output is 0, which is "*ABA*BA" only, but actually I kind hope it
> could find both "*ABA*BA" and "AB*ABA*". Any way to bypass that?
>
> Thanks!
> Regards,
> Yuqiang
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20161210/37027225/attachment.html 


More information about the ncl-talk mailing list