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

Home » Public Forums » archive » checking a special character in a single string
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: checking a special character in a single string [message #93169 is a reply to message #93166] Thu, 05 May 2016 09:08 Go to previous messageGo to previous message
Burch is currently offline  Burch
Messages: 28
Registered: December 2013
Junior Member
On Thursday, May 5, 2016 at 9:28:57 AM UTC-5, Sapna Mishra wrote:
> Hello all,
>
> I have a string say:
> obj='J165248.4+363212.5'
>
> I want to know the place where my this + sign has come say here at 10th place .
>
> I did:
> n=where(strmatch(obj,'+*',/FOLD_CASE) EQ 1)
>
> but it is simply giving me n=1.
>
> can any one tell how to proceed ?
>
> Also if i want to remove all the numbers after '.' (decimal) how to do?
> with strjoin+strsplit it is simply removing decimal sign and clubbing all numbers together. I don't want numbers after decimal how to do???

STRMATCH() doesn't give the location of the search string within the input. It simply returns 1 or 0 based upon whether or not the search string is in the input. Also, when I run your code I get n = -1. To get n=1 the search string for STRMATCH() needs to be '*+*'.

Regardless, if you're looking for the location within the input, then the function you want is STREGEX().

IDL> obj='J165248.4+363212.5'
IDL> print, stregex(obj, '\+')
9

Documentation:
STREGEX(): http://www.harrisgeospatial.com/docs/stregex.html
Regular Expressions: http://www.harrisgeospatial.com/docs/learning_about_regular_ e.html#strings_3486979161_298753
STRMATCH(): http://www.harrisgeospatial.com/docs/strmatch.html#S_8200403 01_679108

-Jeff
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Visualize a Radar image with ENVI
Next Topic: Tool for converting FK4/FK5

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

Current Time: Thu Oct 09 07:50:20 PDT 2025

Total time taken to generate the page: 0.24344 seconds