just show numbers as regex

More
1 month 3 weeks ago #215516 by Cleverly
Hi!
I would like the previously entered date of birth "Birth" DD.MM.YY to be shown in another question in Sufix, but without the dots. So "DDMMYY". {Birth.shown} works, but with the dots. 
The best case would be that you even enter DD.MM.YYYY and the sufix then says "DDMMYY".

Is this possible? It is relevant for the austrian insurance number (for you to know the background)


Best regards

Please Log in to join the conversation.

More
1 month 3 weeks ago #215518 by tpartner
Replied by tpartner on topic just show numbers as regex
Try the ExpressionScript str_replace() function.

- manual.limesurvey.org/ExpressionScript_-...#Access_to_functions

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

More
1 month 3 weeks ago - 1 month 3 weeks ago #215520 by Cleverly
Replied by Cleverly on topic just show numbers as regex
thank you!
Last edit: 1 month 3 weeks ago by Cleverly.

Please Log in to join the conversation.

More
1 month 3 weeks ago - 1 month 3 weeks ago #215524 by Joffm
Replied by Joffm on topic just show numbers as regex
Hi,
this you see in the manual str_replace Replace all occurrences of the search string with the replacement stringstring str_replace(search, replace, subject)
"Search" is "." (the dot)
"Replace" is "" (empty)
"Subject" is your question "birth"

So: {str_replace(".","",birth)}
 


But you did not say, what type of question do you use to capture the birthdate.
We assumed it is a "short text". If you use a "date/time" question it is different, as this question type stores dates as "YYYY-MM-DD".
Here you may use
{str_replace(".","",birth.shown)}
Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
Last edit: 1 month 3 weeks ago by Joffm.

Please Log in to join the conversation.

More
1 month 3 weeks ago #215525 by tpartner
Replied by tpartner on topic just show numbers as regex
{str_replace('.', '', Birth.shown)}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

More
1 month 3 weeks ago - 1 month 3 weeks ago #215530 by Cleverly
Replied by Cleverly on topic just show numbers as regex
yeah it worked perfectly with {str_replace('.', '', Birth.shown)}. Thank you!

Is there a way to change dd.mm.yyyy to ddmmyy?
i tried it with OR and ".19" and ".20" because there is no 19th/20th month. but this doesn't work - not sure if OR is allowed at all...
Last edit: 1 month 3 weeks ago by Cleverly.

Please Log in to join the conversation.

More
1 month 3 weeks ago - 1 month 3 weeks ago #215533 by Joffm
Replied by Joffm on topic just show numbers as regex
Na klar.
manual.limesurvey.org/Question_type_-_Date#Date.2FTime_format

 


So, no "str_replace" needed, just {birth.shown}


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
Last edit: 1 month 3 weeks ago by Joffm.

Please Log in to join the conversation.

More
1 month 3 weeks ago #215538 by Cleverly
Replied by Cleverly on topic just show numbers as regex
no this is no option. Looks really bad for participants...

Please Log in to join the conversation.

More
1 month 3 weeks ago - 1 month 3 weeks ago #215550 by Joffm
Replied by Joffm on topic just show numbers as regex
Oh, I obviously misunderstood.

Well, you may use all implemented string functions.

So this will "convert" 19.06.1956" to "190650"

Either you take the substring of day and month, replace the dot and add the 2-digit-year
{str_replace(".","",substr(birth.shown,0,5))+substr(birth.shown,8,2)}

or you select the three substrings separately
{substr(birth.shown,0,2)+substr(birth.shown,3,2)+substr(birth.shown,8,2)}

 

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
Last edit: 1 month 3 weeks ago by Joffm.

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now