Discussion: Asterisk Expressions

Comments Filter

Using ceil/floor etc

Here is a quick example of using floor

$[FLOOR(${NUMBERWITHDECIMAL})]

I don't know why this wasn't obvious to me, so I thought I would share incase others are lost like me.

by john8675309, Thursday 03 of May, 2012 (21:38:01 UTC)
parsing of utf-8 expressions with asterisk 1.2

The expression parser in v1.2 seems not capable of handling multibyte characters.

by telcat_bremicker, Wednesday 11 of November, 2009 (18:01:58 UTC)
Hidden string length function, the hard way

Here's one that just cost me 2 days. Thought I'd save someone else the trouble. Not sure if this is a bug or a feature. Asterisk will convert the comma (',') character into a vertical bar ('|') automatically in your regex string. Thus, if you are trying to parse something like "success,result" to determine whether a command was successful or not, and you write your regex "(success|fail),.*" (perfectly valid, BTW) Asterisk will convert this to "(success|fail)|.*" behind the scenes. Your regex will thus always match the .* pattern, never match the substring, and return the length of your string!
<P>
This might be intentional, but it sure is confusing, appears to violate the rules, and definitely should be spelled out in big bold letters. If you are going to use a ',' in an Asterisk regex, you had better escape it or prepare to suffer multiple days of torture and eventually dropping into astlog's in the ast_expr2.c file like I did.


by cziom, Wednesday 24 of January, 2007 (10:56:59 UTC)