Hi there,
i have a string field with following bind.
As int can hold only upto 9 digits, that is why string type is being used.
Can regular expressions work with strings?
Regards,
Ayub
Hi there,
i have a string field with following bind.
As int can hold only upto 9 digits, that is why string type is being used.
Can regular expressions work with strings?
Regards,
Ayub
Hi Ayub,
I don't know if the regex engine does well with \b \d. Try something like this.
regex(., [1]{13}')
Yaw
On Mon, Dec 16, 2013 at 9:08 PM, Ayub nrspaggregate@gmail.com wrote:
Hi there,
i have a string field with following bind.
As int can hold only upto 9 digits, that is why string type is being used.
Can regular expressions work with strings?
Regards,
Ayub--
You received this message because you are subscribed to the Google Groups
"ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0-9 ↩︎
That works great Yaw, it just missed single qoute. regex(., '^[0-9]{13}')
at the begining '^... will keep in mind not to use \b \d with ODK.
Thanks for the quick reply,
Regards,
Ayub
Hi Yaw,
It works for 13 or less digits, but it allows more than 13 digits. Any
ideas how can i restrict it to 13, that's why i used \b in regex.
Regards,
Ayub
Make sure you are using the type=string with appearance=numbers. Then
try [1]{13}$. If that fails, please file a bug with a sample form
that shows the bug.
You can also use 'string-length(.) <= 13' as a constraint but regex
should work...
Yaw
On Wed, Dec 18, 2013 at 5:56 AM, Ayub nrspaggregate@gmail.com wrote:
Hi Yaw,
It works for 13 or less digits, but it allows more than 13 digits. Any ideas
how can i restrict it to 13, that's why i used \b in regex.Regards,
Ayub--
You received this message because you are subscribed to the Google Groups
"ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0-9 ↩︎
Hi Ayub,
Remember to use the ^ and $ to denote begining and the end respectively.
ie. try regex(., '^[0-9]{13}$') to limit to 13 digits only.
Regards
Kihara
Thanks Yaw, it works perfectly now, only allows 13 digits no less no more.
I used combination of string-length(.) <= 13 and regex(., '^[0-9]{13}') as
bind constraint, that worked too but your solution is elegant.
Regards,
Ayub
Thank you Kihara for explaining regular expression. regex(., '^[0-9]{13}$')
works perfectly for exactly 13 digits.