I have strings of which I only want the first sentence to return, I tried regex101 to built my regex but when I run the scenario it returns the complete string:
Welcome to the Make community!
According to the Text Parser page in the Make Help Center:
Match Pattern
- For experimenting with regular expressions, we recommend the regular expressions 101 website. Just make sure to tick the ECMAScript (JavaScript) FLAVOR in the left panel.
If you do not do this before using the site, your regex may be incorrect as it uses the PCRE regex by default (which is slightly different from ECMAScript/JS).
Once you select the correct version, you can see why it isn’t working.
Hope this helps!
Alternatively, you can simply use the built-in function split
, then first
to get the first paragraph.
{{ first(split(2.`Copy`; newline)) }}
this works, thanks a lot @samliew
Just fyi regarding your first response when I try to select the ECMA script it shows the same match as the standard selected flavor.
Just to add, for regex I had used .+ to match any character but it doesnt include new lines, I was able to do this with [\S\s]*
^(.+?(?:\.|\?|\!))(?:.+|\n|\s)[\S\s]*
You could also just do (?<text>[^\n]+)
That one includes multiple sentences if it doesnt have a line break…
It seems this is the only that works though I imagine it can be written a bit easier regex101: build, test, and debug regex