String manipulation and query functions.
concat( strings, ... )
s1+s2+...
, but this method makes sure that
values are converted to strings, with the blank value invisible.
strings
(Object, one or more): one or more stringsconcat("blue", "moon") = "bluemoon"
concat("1", 2, 3, "4") = "1234"
concat("Astro", null, "Physics") = "AstroPhysics"
join( separator, words, ... )
separator
(String): string to insert between adjacent wordswords
(Object, one or more): one or more values to joinseparator
join("<->", "alpha", "beta", "gamma")
= "alpha<->beta<->gamma"
join(" ", 1, "brown", "mouse")
= "1 brown mouse"
equals( s1, s2 )
s1==s2
,
which can (for technical reasons) return false even if the
strings are the same.
s1
(String): first strings2
(String): second stringequalsIgnoreCase( s1, s2 )
s1
(String): first strings2
(String): second stringequalsIgnoreCase("Cygnus", "CYGNUS") = true
equalsIgnoreCase("Cygnus", "Andromeda") = false
startsWith( whole, start )
whole
(String): the string to teststart
(String): the sequence that may appear at the start of
whole
whole
are
the same as start
startsWith("CYGNUS X-1", "CYG") = true
endsWith( whole, end )
whole
(String): the string to testend
(String): the sequence that may appear at the end of
whole
whole
are
the same as end
endsWith("M32", "32") = true
contains( whole, sub )
whole
(String): the string to testsub
(String): the sequence that may appear within whole
sub
appears within
whole
contains("Vizier", "izi") = true
length( str )
str
(String): stringstr
length("M34") = 3
split( words )
The result is an array of strings, and if you want to use the
individual elements you need to use square-bracket indexing,
with [0]
representing the first object
words
(String): string with embedded spaces delimiting the wordssplit("211:54:01 +29:33:41")
gives a 2-element array,
first element is "211:54:01"
and
second element is "+29:33:41"
.split(" cat dog cow ")[1] = "dog"
split( words, regex )
The result is an array of strings, and if you want to use the
individual elements you need to use square-bracket indexing,
with [0]
representing the first object
words
(String): string with multiple partsregex
(String): regular expression delimiting the different words in
the words
parametersplit("cat, dog, cow", ", *")
gives a 3-element string array.split("23.0, 45.92", ", ")[0] = "23.0"
parseDouble(split("23.0, 45.92", ", ")[0]) = 23
matches( str, regex )
str
(String): string to testregex
(String): regular expression stringregex
matches str
anywherematches("Hubble", "ub") = true
matchGroup( str, regex )
str
(String): string to match againstregex
(String): regular expression containing a grouped sectionregex
didn't match str
)matchGroup("NGC28948b","NGC([0-9]*)") = "28948"
replaceFirst( str, regex, replacement )
str
(String): string to manipulateregex
(String): regular expression to match in str
replacement
(String): replacement stringstr
, but with the first match (if any) of
regex
replaced by replacement
replaceFirst("Messier 61", "Messier ", "M-") = "M-61"
replaceAll( str, regex, replacement )
str
(String): string to manipulateregex
(String): regular expression to match in str
replacement
(String): replacement stringstr
, but with all matches of
regex
replaced by replacement
replaceAll("1-2--3---4","--*","x") = "1x2x3x4"
substring( str, startIndex )
str
(String): the input stringstartIndex
(integer): the beginning index, inclusivestr
, omitting the first
startIndex
characterssubstring("Galaxy", 2) = "laxy"
substring( str, startIndex, endIndex )
startIndex
and continues to the character at index endIndex-1
Thus the length of the substring is endIndex-startIndex
.
str
(String): the input stringstartIndex
(integer): the beginning index, inclusiveendIndex
(integer): the end index, inclusivestr
substring("Galaxy", 2, 5) = "lax"
toUpperCase( str )
str
(String): input stringstr
toUpperCase("Universe") = "UNIVERSE"
toLowerCase( str )
str
(String): input stringstr
toLowerCase("Universe") = "universe"
trim( str )
str
(String): input stringtrim(" some text ") = "some text"
trim("some text") = "some text"
padWithZeros( value, ndigit )
value
(long integer): numeric value to padndigit
(integer): the number of digits in the resulting stringvalue
with
at least ndigit
characterspadWithZeros(23,5) = "00023"
desigToRa( designation )
2MASS J04355524+1630331
"
following the specifications in the document
https://cdsweb.u-strasbg.fr/Dic/iau-spec.html.
Note: this function should be used with considerable care. Such designators are intended for object identification and not for communicating sky positions, so that the resulting positions are likely to lack precision, and may be inaccurate. If positional information is available from other sources, it should almost certainly be used instead. But if there's no other choice, this may be used as a fallback.
Note also
that a designator with no coordsystem-specific flag character
(a leading "J
", "B
" or "G
")
is considered to be B1950, not J2000.
designation
(String): designation string in IAU formatdesigToRa("2MASS J04355524+1630331") = 60.98016
desigToRa("PSR J120000.0+450000.0") = 180
desigToDec("PSR B120000.0+450000.0") = 180.639096
desigToRa("PN G001.2-00.3") = 267.403
desigToRa("NGC 4993") = NaN
desigToDec( designation )
2MASS J04355524+1630331
"
following the specifications in the document
https://cdsweb.u-strasbg.fr/Dic/iau-spec.html.
Note: this function should be used with considerable care. Such designators are intended for object identification and not for communicating sky positions, so that the resulting positions are likely to lack precision, and may be inaccurate. If positional information is available from other sources, it should almost certainly be used instead. But if there's no other choice, this may be used as a fallback.
Note also
that a designator with no coordsystem-specific flag character
(a leading "J
", "B
" or "G
")
is considered to be B1950, not J2000.
designation
(String): designation string in IAU formatdesigToDec("2MASS J04355524+1630331") = 16.50919
desigToDec("PSR J120000.0+450000.0") = 45
desigToDec("PSR B120000.0+450000.0") = 44.72167
desigToDec("PN G001.2-00.3") = -28.06457
desigToDec("NGC 4993") = NaN
desigToIcrs( designation )
2MASS J04355524+1630331
"
to determine its sky position,
following the specifications in the document
https://cdsweb.u-strasbg.fr/Dic/iau-spec.html.
Obviously, this only works where the sequence part of the designation takes one of the family of coordinate-based forms.
Note: this function should be used with considerable care. Such designators are intended for object identification and not for communicating sky positions, so that the resulting positions are likely to lack precision, and may be inaccurate. If positional information is available from other sources, it should almost certainly be used instead. But if there's no other choice, this may be used as a fallback.
Note also
that a designator with no coordsystem-specific flag character
(a leading "J
", "B
" or "G
")
is considered to be B1950, not J2000.
designation
(String): designation string in IAU formatnull
if no position can be decoded