Next Previous Up Contents
Next: Tilings
Up: General Functions
Previous: General Functions

### B.1.1 Strings

String manipulation and query functions.

`concat( strings, ... )`
  Concatenates multiple values into a string. In some cases the same effect can be achieved by writing `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 strings
  - return value (String): concatenation of input strings, without separators
`join( separator, words, ... )`
  Joins multiple values into a string, with a given separator between each pair.
  - `separator` (String): string to insert between adjacent words
  - `words` (Object, one or more): one or more values to join
  - return value (String): input values joined together with `separator`
`equals( s1, s2 )`
  Determines whether two strings are equal. Note you should use this function instead of `s1==s2`, which can (for technical reasons) return false even if the strings are the same.
  - `s1` (String): first string
  - `s2` (String): second string
  - return value (boolean): true if s1 and s2 are both blank, or have the same content
`equalsIgnoreCase( s1, s2 )`
  Determines whether two strings are equal apart from possible upper/lower case distinctions.
  - `s1` (String): first string
  - `s2` (String): second string
  - return value (boolean): true if s1 and s2 are both blank, or have the same content apart from case folding
`startsWith( whole, start )`
  Determines whether a string starts with a certain substring.
  - `whole` (String): the string to test
  - `start` (String): the sequence that may appear at the start of `whole`
  - return value (boolean): true if the first few characters of `whole` are the same as `start`
`endsWith( whole, end )`
  Determines whether a string ends with a certain substring.
  - `whole` (String): the string to test
  - `end` (String): the sequence that may appear at the end of `whole`
  - return value (boolean): true if the last few characters of `whole` are the same as `end`
`contains( whole, sub )`
  Determines whether a string contains a given substring.
  - `whole` (String): the string to test
  - `sub` (String): the sequence that may appear within `whole`
  - return value (boolean): true if the sequence `sub` appears within `whole`
`length( str )`
  Returns the length of a string in characters.
  - `str` (String): string
  - return value (integer): number of characters in `str`
`split( words )`
  Splits a string into an array of space-separated words. One or more spaces separates each word from the next. Leading and trailing spaces are ignored.

  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 words
  - return value (array of String): array of the separate words; you can extract the individual words from the result using square bracket indexing
`split( words, regex )`
  Splits a string into an array of words separated by a given regular expression.

  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 parts
  - `regex` (String): regular expression delimiting the different words in the `words` parameter
  - return value (array of String): array of the separate words; you can extract the individual words from the result using square bracket indexing
`matches( str, regex )`
  Tests whether a string matches a given regular expression.
  - `str` (String): string to test
  - `regex` (String): regular expression string
  - return value (boolean): true if `regex` matches `str` anywhere
`matchGroup( str, regex )`
  Returns the first grouped expression matched in a string defined by a regular expression. A grouped expression is one enclosed in parentheses.
  - `str` (String): string to match against
  - `regex` (String): regular expression containing a grouped section
  - return value (String): contents of the matched group (or null, if `regex` didn't match `str`)
`replaceFirst( str, regex, replacement )`
  Replaces the first occurrence of a regular expression in a string with a different substring value.
  - `str` (String): string to manipulate
  - `regex` (String): regular expression to match in `str`
  - `replacement` (String): replacement string
  - return value (String): same as `str`, but with the first match (if any) of `regex` replaced by `replacement`
`replaceAll( str, regex, replacement )`
  Replaces all occurrences of a regular expression in a string with a different substring value.
  - `str` (String): string to manipulate
  - `regex` (String): regular expression to match in `str`
  - `replacement` (String): replacement string
  - return value (String): same as `str`, but with all matches of `regex` replaced by `replacement`
`substring( str, startIndex )`
  Returns the last part of a given string. The substring begins with the character at the specified index and extends to the end of this string.
  - `str` (String): the input string
  - `startIndex` (integer): the beginning index, inclusive
  - return value (String): last part of `str`, omitting the first `startIndex` characters
`substring( str, startIndex, endIndex )`
  Returns a substring of a given string. The substring begins with the character at `startIndex` and continues to the character at index `endIndex-1` Thus the length of the substring is `endIndex-startIndex`.
  - `str` (String): the input string
  - `startIndex` (integer): the beginning index, inclusive
  - `endIndex` (integer): the end index, inclusive
  - return value (String): substring of `str`
`toUpperCase( str )`
  Returns an uppercased version of a string.
  - `str` (String): input string
  - return value (String): uppercased version of `str`
`toLowerCase( str )`
  Returns an lowercased version of a string.
  - `str` (String): input string
  - return value (String): lowercased version of `str`
`trim( str )`
  Trims whitespace from both ends of a string.
  - `str` (String): input string
  - return value (String): str with any spaces trimmed from start and finish
`padWithZeros( value, ndigit )`
  Takes an integer argument and returns a string representing the same numeric value but padded with leading zeros to a specified length.
  - `value` (long integer): numeric value to pad
  - `ndigit` (integer): the number of digits in the resulting string
  - return value (String): a string evaluating to the same as `value` with at least `ndigit` characters
`desigToRa( designation )`
  Attempts to determine the ICRS Right Ascension from an IAU-style designation such as "`2MASS J04355524+1630331`" following the specifications in the document http://cds.u-strasbg.fr/vizier/Dic/iau-spec.htx.

  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 format
  - return value (floating point): ICRS right ascension in degreees, or blank if no position can be decoded
`desigToDec( designation )`
  Attempts to determine the ICRS Declination from an IAU-style designation such as "`2MASS J04355524+1630331`" following the specifications in the document http://cds.u-strasbg.fr/vizier/Dic/iau-spec.htx.

  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 format
  - return value (floating point): ICRS declination in degrees, or blank if no position can be decoded
`desigToIcrs( designation )`
  Attempts to decode an IAU-style designation such as "`2MASS J04355524+1630331`" to determine its sky position, following the specifications in the document http://cds.u-strasbg.fr/vizier/Dic/iau-spec.htx.

  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 format
  - return value (array of floating point): 2-element array giving ICRS (RA,Dec) in degrees, or `null` if no position can be decoded

Next Previous Up Contents
Next: Tilings
Up: General Functions
Previous: General Functions

TOPCAT - Tool for OPerations on Catalogues And Tables
Starlink User Note253
TOPCAT web page: http://www.starlink.ac.uk/topcat/
Author email: m.b.taylor@bristol.ac.uk
Mailing list: topcat-user@jiscmail.ac.uk