Extracting info from an intake form using regex

Hi :wave:t3:

I am trying to write a snippet to extract data from my intake form into my clinical notes.

Here is what I have so far. Some of the command work but others don't so I'm hoping someone can help me figure out why.

I'll paste the info from my intake form below so you can see how it's formatted in the clipboard and also attach photos of what's happening when I use the snippet. I'll also attach a couple of screen shots which show how the form is displayed in my Practice Management Software (only really for clarity).

Just as a side note, when I type out "Birth weight 3500 and Day 3 or discharge weight 3150" into another app and copy that to clipboard that section of the snippet works. However, as you can see, it doesn't work when copied from the form.

Client's Name: {=extractregex({clipboard}, "First Name

Baby's name: {=extractregex({clipboard}, "Baby's Name

Baby's DOB: {=extractregex({clipboard}, "Baby's DOB

{formmenu: Older Child; default=Older Children}: {note: preview=yes}{formtoggle: name=other kids; default=yes}{note: preview=no}No{endnote}{endformtoggle} {endnote}{if: `other kids`}{=extractregex({clipboard}, "If you are not a first time mother please provide the name/s and D.O.B. of your other children

Partner's name: {note: preview=yes}{formtoggle: name=Name on form; default=no}{note: preview=no}No name on form{endnote}{endformtoggle} {endnote}{if: `name on form`}{=extractregex({clipboard}, "Full Name
(\w+)")}{else}No name on form{endif}

Is {=extractregex({clipboard}, "Baby's Name
(\w+)")} being fed responsively (on demand) or on a schedule?
{=extractregex({clipboard}, "Is baby being fed responsively (on demand) or on a schedule?(\w+)")}

Average number of breastfeeds in a 24 hour period?
{=extractregex({clipboard}, "Average number of breastfeeds in a 24 hour period?(.+)")}

What are your breastfeeding goals?
{=extractregex({clipboard}, "What are your breastfeeding goals?

{note: preview=no}
{`birth weight`=extractregex({clipboard}, "Birth weight
(\w+)")} - {`current weight`=extractregex({clipboard}, "Day 3 or discharge weight
(\w+)")}= {=`birth weight`-`current weight`}{endnote}
Percentage weight loss
Weight lost ({=`birth weight`-`current weight`}) / Birth weight ({=`birth weight`}) = {={=`birth weight`-`current weight`} / `birth weight`; format=,.2f}
{={=`birth weight`-`current weight`} / `birth weight`; format=,.2f} * {formtext: name=100; default=100} =
{={={=`birth weight`-`current weight`} / `birth weight`}*`100`; format=,.2f}% {formtext: name=(Day ?)}

Copied from intake form:

First Name
Last Name
Preferred Name
Date of Birth
Mobile Number
Mobile: +61 0400400400
1 Example Address, Gold Coast, Qld, 4000, Australia
No response
If you are not a first time mother please provide the name/s and D.O.B. of your other children
Grace 01/05/2012 & Lachlan 16/08/2016
Full Name
No response
Are they currently on paternity leave? If so, for how long?
2 weeks
Baby's Name
Baby's DOB
2 Mar 2023
How old will baby be on the day of the consultation?
18 days

Birth weight
Day 3 or discharge weight

Is baby being fed responsively (on demand) or on a schedule?
Are both breasts being OFFERED every feed? (NB: This is different than baby actually taking both breasts at every feed)
Average number of breastfeeds in a 24 hour period?
Have you previously sought assistance elsewhere?
Do you feel supported by your partner and/or other people close to you? (This information is used only to assist me to develop a customised care plan specific to your needs. Your answer is kept strictly confidential)
What are your breastfeeding goals?
To feed pain-free and not worry whether Max is getting enough milk.

Any assistance you can give me would be very much appreciated.

~ Bec

Hey again @Bec_Dawson :wave:

It's hard to figure out the exact issue here. My guess is that you have more than one whitespace character while copy pasting those fields. So, I would suggest adding a whitespace separator like this:

{data="Birth weight
{`birth weight`=extractregex(data, "Birth weight\s*(\w+)")}{=`birth weight`}

\s* means zero or more whitespace characters (spaces/newlines/tabs/etc.). Let me know if it works for you.

Thanks heaps Gaurang, the "Day 3 or discharge weight" is now working!
It didn't work for any of the other commands though. I think that might be because I'm using the incorrect regex though. I've spent so long trying to figure it out that I feel like I've tried all the combinations I've seen in the videos and on the help page and now I'm just confused :woman_facepalming:t3:


The regex seems fine to me. Are there any special characters while copy pasting? You can open https://regex101.com/ and:

  1. copy and paste from your intake form into the "Test string" section
  2. paste your regex in the "Regular expression"

and then see if it produces a match. This page will highlight any special characters that we are missing visually.