Home »
Public Forums »
archive »
Re: Removing (or replacing) substrings in a string array
Re: Removing (or replacing) substrings in a string array [message #84595] |
Wed, 22 January 2014 08:36 |
Mats Löfdahl
Messages: 263 Registered: January 2012
|
Senior Member |
|
|
Den onsdagen den 22:e januari 2014 kl. 16:57:50 UTC+1 skrev Fabien:
> ... if I might sneak into this post: is there a general solution for the
> problem:
>
> "Removing (or replacing) all occurences of a substring of any length in
> a string array" ?
>
> This sounds like such a trivial and usefull operation that I wonder why
> it is not native in the IDL language...
>
> I rely on this solution which I found on the newsgroup:
>
> https://groups.google.com/d/msg/comp.lang.idl-pvwave/4eq9yOP NTJ8/mDltqt72pogJ
>
> There is also the Astro solution:
>
> http://www.astro.washington.edu/docs/idl/cgi-bin/getpro/libr ary27.html?STRREPLACE
>
> But it would be nice to have a unified and fast solution, no?
>
> Is there one already?
>
> Thanks!
Looks like it would be possible to do this with the regular subexpressions. Instead of keeping the matching row in the 2D array that you get from stregex, you should be able to piece together all the other parts, optionally with a string replacing that row instead of removing it.
If it's fast I don't know. But at least it's not loop based like strreplace
|
|
|
Current Time: Wed Oct 08 13:58:20 PDT 2025
Total time taken to generate the page: 0.00280 seconds