Clay Icon

Guidelines for Extracting First Names from a List

·
·

Hi Guys, I am trying to clean up the first names in my list. However, I am unable to fix the name starting with a single letter and then First name. For example: "D. Adam Walker" still gives me the output D. Attached my AI Prompt formula: Extract the first name from "Full Name" based on these rules: - If the name starts with "Dr.", return "Dr." followed by the first name. - If the name starts with a **single letter (e.g., "T Madden Alford" or "D.Adam Gevanter")**, ignore the first letter and return the next full word with only the first letter capitalized. - Otherwise, return just the first name with the first letter capitalized. Example Inputs & Expected Outputs: - "dr. john doe" → "Dr. John" - "Dr. Sarah Smith" → "Dr. Sarah" - "george WASHINGTON" → "George" - "jane doe" → "Jane" - "D.Adam Gevanter" → "Adam" - "M. John Smith" → "John" - "T Madden Alford" → "Madden"

  • Avatar of Channeled
    Channeled
    APP
    ·
    ·

    If your current AI prompt isn't giving you the desired results, here are the steps to improve it: 1. Use the "Help me" button next to the prompt field to refine your formula. This feature acts as a metaprompter to help optimize your current prompt. 2. When writing your prompt, remember to: • Set clear context • Provide step-by-step instructions • Be explicit about the output format you want If the AI still doesn't give you exactly what you're looking for on the first try, you can: ** Iterate on your prompts ** Adjust the wording ** Directly modify the generated code ** Use the preview feature to test your results before applying the formula

  • Avatar of Channeled
    Channeled
    APP
    ·
    ·

    Did that answer your question?

  • Avatar of Sahil S.
    Sahil S.
    ·
    ·

    Attached image screenshot for clarity

  • Avatar of Channeled
    Channeled
    APP
    ·
    ·

    Looks like you're still looking for help.

    If you’re dealing with a specific table, drop the URL below so we can help you quicker. Otherwise, someone from our team will be in touch soon!

  • Avatar of Bo (.
    Bo (.
    ·
    ·

    Hi!

    I modified the JS script using an LLM for better variation handling. At Clay we use a single line of vanilla JavaScript, so you can say: I'm using this JS (add the formula generated) but I want to (add what you want) Here's a prompt you can use to get the same results I need a Clay.js JavaScript formula that extracts and cleans first names from full names. The formula should handle these specific cases in order:

    1. If the name starts with 'Dr.' (case insensitive), return 'Dr.' followed by the first name properly capitalized. Example: 'dr. john smith' → 'Dr. John' 2. If the name starts with a single letter followed by either a dot or space, ignore that initial and return the next word properly capitalized. Examples: 1. 'D.Adam Smith' → 'Adam' 2. 'T Madden Alford' → 'Madden' 3. 'M. John Smith' → 'John' 1. For all other cases, return just the first word properly capitalized. Example: 'george WASHINGTON' → 'George' Requirements:

    1. Formula must be in a single line of vanilla JavaScript. 2. Use optional chaining (?.) to handle null values safely. 3. Use regex patterns with match() to identify name components. 4. Convert final output to proper case (first letter capitalized, rest lowercase). 5. Handle each case in order of priority (Dr. → single letter initial → regular name). Return undefined/null if no valid name is found. 7. Formula should work with {{Full Name}} as the input field in Clay.js. Here's the formula I'm using now:

    Let me know if you need more help with this!

  • Avatar of Channeled
    Channeled
    APP
    ·
    ·

    Hi Sahil S.! This thread was recently closed by our Support team. If you have a moment, please share your feedback:

  • Avatar of Channeled
    Channeled
    APP
    ·
    ·

    Thank you so much for sharing your feedback Sahil S.!

  • Avatar of Channeled
    Channeled
    APP
    ·
    ·

    Thank you so much for sharing your feedback Sahil S.!