<div style="white-space:pre-wrap">Hi Dennis,<br><br>That does makes sense. Thanks for the quick function!<br><br>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.<br><br>Thanks!<br><br>Regards,<br>Yuqiang</div><br><div class="gmail_quote"><div dir="ltr">On Fri, Dec 9, 2016 at 4:55 PM Dennis Shea <<a href="mailto:shea@ucar.edu">shea@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">This would require 'recursive' searching.... letter-by-letter<br class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">ABAABA , ..... NC=7 (# characters)<br class="gmail_msg">0123456<br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">[0[ set 'idx=0'<br class="gmail_msg"></div><div class="gmail_msg">[1] Find 'ABA', success; IDX = 0<br class="gmail_msg"></div><div class="gmail_msg">[2] set 'idx=1', and search the string BAABA<br class="gmail_msg"></div><div class="gmail_msg">[3] Find 'ABA', success, set IDX = (/0,4/)<br class="gmail_msg"></div><div class="gmail_msg">[4] set idx=5<br class="gmail_msg"></div><div class="gmail_msg">[5] repeat .... ad infinitum <br class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I think you could write a function that does that. <br class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">undef("get_many_index_str")<br class="gmail_msg"></div><div class="gmail_msg">function get_many_index_str(str:string)<br class="gmail_msg"></div><div class="gmail_msg">begin<br class="gmail_msg"> ...<br class="gmail_msg"></div><div class="gmail_msg"> return(IDX)<br class="gmail_msg"></div><div class="gmail_msg">end<br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Why does NCL not do that? Well, let's say NC=1000000<br class="gmail_msg"></div><div class="gmail_msg">This would be VERY time consuming.</div></div><br class="gmail_msg"></div><div class="gmail_extra gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg"></div></div><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg">On Fri, Dec 9, 2016 at 2:31 PM, Yuqiang Zhang <span dir="ltr" class="gmail_msg"><<a href="mailto:yuqiangzhang.thu@gmail.com" class="gmail_msg" target="_blank">yuqiangzhang.thu@gmail.com</a>></span> wrote:<br class="gmail_msg"></div></div><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg">Hi Dear NCL developers, <div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I was using the "str_index_of_substr" to find the sub array recently, and found some interesting thing about it. </div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">For example, </div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">a = "ABABA"</div><div class="gmail_msg">substr = "ABA"</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">i1 = str_index_of_substr(a, substr, 0)</div><div class="gmail_msg">print(i1)</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">The output is 0, which is "<b class="gmail_msg">ABA</b>BA" only, but actually I kind hope it could find both "<b class="gmail_msg">ABA</b>BA" and "AB<b class="gmail_msg">ABA</b>". Any way to bypass that?</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Thanks! </div><div class="gmail_msg">Regards,</div><div class="gmail_msg">Yuqiang</div></div>
<br class="gmail_msg"></blockquote></div></div><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">_______________________________________________<br class="gmail_msg">
ncl-talk mailing list<br class="gmail_msg">
<a href="mailto:ncl-talk@ucar.edu" class="gmail_msg" target="_blank">ncl-talk@ucar.edu</a><br class="gmail_msg">
List instructions, subscriber options, unsubscribe:<br class="gmail_msg">
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" class="gmail_msg" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br class="gmail_msg">
<br class="gmail_msg"></blockquote></div><br class="gmail_msg"></div>
</blockquote></div>