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

Dennis Shea shea at ucar.edu
Fri Dec 9 14:55:53 MST 2016


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/20161209/2f506bc6/attachment.html 


More information about the ncl-talk mailing list