# Asterisk Project : Expressions Examples

Added by mdavenport , edited by mdavenport on Aug 31, 2010

*"One Thousand Five Hundred" =~ "(T[Expressions Examples^ ])"
returns: Thousand

- "One Thousand Five Hundred" =~ "T[Expressions Examples^ ]"
  returns: 8

- "One Thousand Five Hundred" : "T[Expressions Examples^ ]"
  returns: 0

- "8015551212" : "(...)"
  returns: 801

- "3075551212":"...(...)"
  returns: 555

- ! "One Thousand Five Hundred" =~ "T[Expressions Examples^ ]"
  returns: 0
  (because it applies to the string, which is non-null, which it turns to "0", and then looks for the pattern in the "0", and doesn't find it)

- !( "One Thousand Five Hundred" : "T[Expressions Examples^ ]+" )
  returns: 1
  (because the string doesn't start with a word starting with T, so the match evals to 0, and the ! operator inverts it to 1 )

- 2 + 8 / 2
  returns: 6
  (because of operator precedence; the division is done first, then the addition)

- 2+8/2
  returns: 6
  Spaces aren't necessary

- (2+8)/2
  returns: 5
  of course

- (3+8)/2
  returns: 5.5

- TRUNC((3+8)/2)
  returns: 5

- FLOOR(2.5)
  returns: 2

- FLOOR(-2.5)
  returns: -3

- CEIL(2.5)
  returns: 3

- CEIL(-2.5)
  returns: -2

- ROUND(2.5)
  returns: 3

- ROUND(3.5)
  returns: 4

- ROUND(-2.5)
  returns: -3

- RINT(2.5)
  returns: 2

- RINT(3.5)
  returns: 4

- RINT(-2.5)
  returns: -2

- RINT(-3.5)
  returns: -4

- TRUNC(2.5)
  returns: 2

- TRUNC(3.5)
  returns: 3

- TRUNC(-3.5)
  returns: -3

Of course, all of the above examples use constants, but would work the same if any of the numeric or string constants were replaced with a variable reference ${CALLERID(num)}, for instance.