Hello Bubble Enthusiasts!
Have you ever struggled with text inputs, validations, or dynamic extractions in your Bubble workflows? Regex (Regular Expressions) can be your best friend! Here’s a collection of regex patterns that are super handy for building smarter apps in Bubble.
1. Email Validation
- Regex:
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
- Why it’s useful: Validate user emails during signups or in forms!
- Example:
example@bubble.io
2. Extract Numbers from Text
- Regex:
\d+
- Why it’s useful: Perfect for pulling numbers out of mixed text fields (e.g., prices or IDs).
- Example: From
Order #12345
, it extracts12345
.
3. Hashtag Detection
- Regex:
#\w+
- Why it’s useful: Use this to find hashtags in user-generated content. Great for building social media-style apps.
- Example: From
#BubbleIsAwesome
, it extracts#BubbleIsAwesome
.
4. Phone Number Validation
- Regex:
^\+?[1-9]\d{1,14}$
- Why it’s useful: Ensures phone numbers are valid and in international format.
- Example:
+1234567890
5. Password Strength Validation
- Regex:
^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$
- Why it’s useful: Build a custom signup form that enforces strong passwords.
- Example: Matches
Secure@123
.
6. URL Validation
- Regex:
https?:\/\/(www\.)?[a-zA-Z0-9-]+\.[a-z]{2,}(\S*)?
- Why it’s useful: Verify user-provided links in forms or inputs.
- Example: Validates
https://bubble.io
.
7. Duplicate Word Detection
- Regex:
\b(\w+)\b\s+\b\1\b
- Why it’s useful: Finds typos like “the the” in text.
- Example: From
This is is fun
, it catchesis is
.
8. Extract Hex Color Codes
- Regex:
#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})
- Why it’s useful: Handy for apps where users input color codes.
- Example: Extracts
#ffffff
or#abc
.
9. Validate Dates (YYYY-MM-DD)
- Regex:
^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$
- Why it’s useful: Enforce proper date formats for input fields.
- Example: Validates
2024-12-30
.
10. File Name Extraction
- Regex:
([^\/]+)$
- Why it’s useful: Extracts just the file name from a file path.
- Example: From
/uploads/image.jpg
, it getsimage.jpg
.
How to Use These in Bubble:
- Add a Regex Pattern in a Workflow action or condition.
- Use these patterns in input validation, custom filtering, or extracting text.
- Bonus: Combine with Bubble’s “Extract with Regex” function for maximum power!
Let’s Discuss!
Which of these patterns do you find the most useful? Have you used regex in your Bubble projects before? Share your use cases or regex hacks below. Let’s inspire each other!
Cheers,
Abdullah