Support Forum

Ask questions and get help from MobileTogether experts.
MobileTogether Product Information
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
View
Go to last post Go to first unread
Mark Cormier  
#1 Posted : Sunday, February 11, 2018 9:53:01 PM(UTC)
Mark Cormier

Rank: Newbie

Groups: Registered
Joined: 9/8/2017(UTC)
Posts: 8
United States
Location: MA

Thanks: 2 times
To All,
Could you provide a working example of the 'string-format()' function found in the Expression Builder? I can't seem to get it to work properly. I am trying display a properly formatted telephone number (i.e. '(555) 555-1111') after user simply enters the number data in an 'edit field'. Thank you in advance...
AFC  
#2 Posted : Wednesday, February 14, 2018 1:21:56 PM(UTC)
AFC

Rank: Administration

Groups: Registered, Administrators
Joined: 9/15/2014(UTC)
Posts: 46
Austria

Was thanked: 8 time(s) in 8 post(s)
Hello Mark!

The XPath/XQuery standard does not specify number format strings as you would need here (also see XPath number formatting picture string).

So we would suggest to use regex replace, e.g.
Quote:
replace( "5555551111", "^(\d{3})(\d{3})(\d+)$", "($1) $2-$3" )

will return
Quote:
"(555) 555-1111"


Attached is also a small sample which allows to enter numbers in an Edit Field and shows the formatted telephone number in a Label.

Does this help?

Best regards,
AFC
File Attachment(s):
FormatStringFunction.mtd (5kb) downloaded 4 time(s).
thanks 1 user thanked AFC for this useful post.
Mark Cormier on 2/14/2018(UTC)
Mark Cormier  
#3 Posted : Wednesday, February 14, 2018 2:01:40 PM(UTC)
Mark Cormier

Rank: Newbie

Groups: Registered
Joined: 9/8/2017(UTC)
Posts: 8
United States
Location: MA

Thanks: 2 times
AFC,
Thank you again, I was able to accomplish this with a combination of stringsub and concat functions, but your way is a little more elegant.
Mark



Originally Posted by: AFC Go to Quoted Post
Hello Mark!

The XPath/XQuery standard does not specify number format strings as you would need here (also see XPath number formatting picture string).

So we would suggest to use regex replace, e.g.
Quote:
replace( "5555551111", "^(\d{3})(\d{3})(\d+)$", "($1) $2-$3" )

will return
Quote:
"(555) 555-1111"


Attached is also a small sample which allows to enter numbers in an Edit Field and shows the formatted telephone number in a Label.

Does this help?

Best regards,
AFC


Users browsing this topic
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.