Stream: shorthand
Topic: Strange error about a string
Jean Duteau (Jun 09 2021 at 23:32):
I have this invariant expression:
Expression: "(system = 'phone' or system = 'fax') implies value.matches('^+d{1,3}-d{1,3}-d{3,4}-d{4}(;ext\=d+)?$')"
And it causes this error:
mismatched input '"(system' expecting STRING
I'm assuming it has something to do with my regex, but this line is just fine:
Expression: "country = 'USA' implies postalCode.matches('^d{5}(-d{4})?$')"
I don't see anything obvious...
Jean Duteau (Jun 09 2021 at 23:33):
nm, solved it. it's the '\' character. that needs to be escaped.
Elliot Silver (Jun 10 2021 at 15:47):
@Jean Duteau, does that mean you don't allow phone numbers of the form "tel://..."? :grinning_face_with_smiling_eyes:
Jean Duteau (Jun 10 2021 at 15:59):
yep. we have a pretty strict telephone requirement for this project. they actually have to look like real telephone numbers. the work I've done to take V3 TEL and parse it to FHIR ContactPoints has been fun.
Jean Duteau (Jun 10 2021 at 16:00):
BTW, for those who might care, here is the regexs for tel/fax and emails:
Expression: "(system = 'phone' or system = 'fax') implies value.matches('^\\\\+[0-9]{1,3}-[0-9]{1,3}-[0-9]{3,4}-[0-9]{4}(;ext=[0-9]+)?$')"
Expression: "system = 'email' implies value.matches('^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(\\\\.[a-zA-Z0-9-]+)*$')"
David Pyke (Jun 10 2021 at 16:34):
So, not just XTN format?
Elliot Silver (Jun 10 2021 at 17:06):
Do you mean to allow two digit area codes, exchange codes and station numbers? Area codes and exchange codes starting with zero or one? Exchange codes of x11? Disallow numbers outside NANP areas?
Jean Duteau (Jun 10 2021 at 17:48):
I'll admit that it's not the most complete regex in that it allows numbers that might not be valid, but, as far as I know, all valid numbers will pass that regex.
David Pyke (Jun 10 2021 at 17:49):
This is what I've used in the past : ^(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$
David Pyke (Jun 10 2021 at 17:50):
That only works for NA numbers.
Last updated: Apr 12 2022 at 19:14 UTC