Forum Documentation Showcase Pricing Learn more

Regex - capture string and the next line


#1

I’m wanting to capture a string and the next line using Regex. I’ve successfully implemented this in Regexr - https://regexr.com/3pej0, but can’t replicate this in Bubble that returns an empty value.

The input is below (possibly relevant - the input is saved in the database as text, and I apply “extract with Regex” on the database entry to generate a new database entry):
Monday 14 May
*12:15pm // *Example event venue
*This is an event name *

The regex is below (I’ve “anchored” the regex on capturing the am or pm characters first, since these are consistently present, whereas the asterisks are not consistently present in this event listing):
(.(am|pm)(.//))((.*(\n|\r|\t)){2})

Would love some assistance. Thanks in advance :slight_smile:


#2

Solved, apparently the database entries (when you click to edit the individual entry) that looks wrapped as a single line, aren’t actually extracted by this regex as a single line. Each line of text is actually counted as though they are separated by a return carriage (\r).


#3

Hey Sherman, I am struggling with a Regex myself when it comes to extracting from different lines of text in a list of texts. I am hoping you can help me.

Basically I want to extract everything between the brackets in the string. Example:
image
I use Regex: (?<=().*?(?=))
In the strings with a new line, it returns empty results.

Here it works in regex101: https://regex101.com/r/15LPhJ/2

But there I can set the regex flag to /gms, where as in bubble it seems to be default /gm and I could not figure out how to change it or go around it. Would appreciate any help… thanks!


#4

Try this mate, the capturing group in the middle [\s\S]*? will help pick up stuff even if it spills over into new lines. Should work in Bubble since it works on Regexr (just remove the 2x spaces after the backslashes)

(\ ()[\s\S]*?(\ ))

https://regexr.com/3sa8t


#5

Thank you so much for the idea. [\s\S] didn’t work with the html strings for some reason, but I tried (?<=()[\D\d]*?(?=)) with the same idea, and that worked perfectly. Thank you for putting me on the right thinking path!


#6

Great! Good to hear :slight_smile:


#7

This topic was automatically closed after 70 days. New replies are no longer allowed.