## org.das2.util.StringTransmogrifier

Apply an operation to a String to make it a String with similar meaning. This is needed for new code which indicates the orbit number, but the orbit number context is provided elsewhere on the plot. https://calvinandhobbes.fandom.com/wiki/Transmogrifier_Gun?file=CalvinTransmogrifierGunWeb.jpg A regular expression specifies the text to look for in strings, and the result is reformatted using a result template string. The transmogrify method will convert the input string to the template, so for example:

    %{@code
     st= StringTransmogrifier('([a-z]+)=([0-9]+)','$1:$2')
     st.transmogrify('cat=1')   # results in 'cat:1'
     }

## StringTransmogrifier( String regex, String result )

Create a regex-based transmogrifier. The result is the template which is populated from groups of the regular expression. The groups can be referenced by index or by name, with

- $<num> by index, where 1 is the first group number
- $<letter> by 1-letter named group
- $<{name}> by named group

## find

find( String string ) → String

replace all matches of the `regex` in `string` with `result`.

### Parameters

string - the string containing any text to transmogrify

### Returns:

the string with each match reformatted within the string
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## transmogrify

transmogrify( String string ) → String

Transmogrify the string, and if it does not match the regex, then an IllegalArgumentException is thrown.

### Parameters

string - the string to transmogrify

### Returns:

the formatted result
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## transmogrify

transmogrify( String string, String err ) → String

Transmogrify the string, and if it does not match the regex, then return err.

### Parameters

string - the string to transmogrify
err - alternate string (or null) to return

### Returns:

the formatted result or the `err` string
[search for examples] [view on GitHub] [view on old javadoc] [view source]