Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

just show numbers as regex

  • Cleverly
  • Cleverly's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 11 months ago #215516 by Cleverly
just show numbers as regex was created 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
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 11 months 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.
The topic has been locked.
  • Cleverly
  • Cleverly's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 11 months ago - 2 years 11 months ago #215520 by Cleverly
Replied by Cleverly on topic just show numbers as regex
thank you!
Last edit: 2 years 11 months ago by Cleverly.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 11 months ago - 2 years 11 months 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
Last edit: 2 years 11 months ago by Joffm.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 11 months ago #215525 by tpartner
Replied by tpartner on topic just show numbers as regex
Code:
{str_replace('.', '', Birth.shown)}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • Cleverly
  • Cleverly's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 11 months ago - 2 years 11 months 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: 2 years 11 months ago by Cleverly.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 11 months ago - 2 years 11 months ago #215533 by Joffm
Replied by Joffm on topic just show numbers as regex
Na klar.
[url] manual.limesurvey.org/Question_type_-_Date#Date.2FTime_format [/url]

 


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

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 years 11 months ago by Joffm.
The topic has been locked.
  • Cleverly
  • Cleverly's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 11 months ago #215538 by Cleverly
Replied by Cleverly on topic just show numbers as regex
no this is no option. Looks really bad for participants...
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 11 months ago - 2 years 11 months 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
Last edit: 2 years 11 months ago by Joffm.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose