HyperMath

The String Library

The String Library

Previous topic Next topic No expanding text in this topic  

The String Library

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  

HyperMath supplies a range of useful functions for processing and manipulating strings in its standard library.  See String Library for more information.  Below are some examples of using the string library.

> print(StrFind("hello HyperMath user", "HyperMath")) // find substring "HyperMath"

7       15          //H occurs at 7th space & h occurs at 15th space

 

> print(StrFind("hello HyperMath user", "l+")) // find one or more occurrences of "l"

3       4

 

> print(StrFormat("%.7f", PI)) // format a number

3.1415927

 

> print(StrFormat("%s", "HyperMath")) // format a string

 HyperMath

 

> print(StrFormat("%s %.7f", "HyperMath", PI)) // Multiple formats

 HyperMath 3.1415927

 

> print(StrFormat("%s %.3f", "HyperMath", PI)) // Multiple formats

 HyperMath 3.142

 

> pi = StrFormat("%.3f", PI)

> print(pi)

3.142