comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: String Spliting
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: String Spliting [message #49358 is a reply to message #49357] Wed, 19 July 2006 09:51 Go to previous messageGo to previous message
ChristopherFlorio is currently offline  ChristopherFlorio
Messages: 23
Registered: April 2006
Junior Member
Thanks. Works fine now.

Michael Galloy wrote:
> ChristopherFlorio@gmail.com wrote:
>> I am having a problem with the STRSPLIT function.
>> I am using it to extract the file extension from a string where it
>> might not be at the end.
>> However in the process I am also eliminating addition elements, not
>> found in the extension.
>> For example
>>
>> file='Image.img'
>> filter='*.img'
>>
>> file=STRJOIN(STRSPLIT(file,filter,/EXTRACT))
>>
>> file='Iae'
>>
>> desired output:
>> file='Image'
>>
>> Is there a way, with the same input as above, not to extract individual
>> parts of the name found in the filter/pattern?
>>
>
> From the docs, about a normal "filter" argument:
>
> "One or more single characters, each of which is considered to be a
> separator. String will be split when any of the characters is detected.
> For example, if Pattern is " ," String will be split whenever either a
> space or a comma is detected. In this case, IDL performs a simple string
> search for the specified characters. This method is simple and fast."
>
> But the filter can also be a regular expression:
>
> IDL> file = 'Image.img'
> IDL> filter = '\.img'
> IDL> print, strjoin(strsplit(file, filter, /regex, /extract))
> Image
>
> The "\" is needed in the filter to escape "."'s special meaning (it
> matches any character).
>
> By the way, the docs on a regular expression "filter" argument:
>
> "If the REGEX keyword is specified, Pattern is considered to be a single
> regular expression (as implemented by the STREGEX function). This method
> is slower and more complex, but can handle extremely complicated Pattern
> strings."
>
> If you want more information about regular expressions, see
>
> http://michaelgalloy.com/2006/06/11/regular-expressions.html
>
> Mike
> --
> www.michaelgalloy.com
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Surface plots in spherical coordinates
Next Topic: Re: mpfitexpr using functargs

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 14:14:18 PDT 2025

Total time taken to generate the page: 0.72044 seconds