'Matching regex for text entry in Qualtrics (JavaScript)

In an open text entry question on Qualtrics, I am adding a validation using regex ("match regex" condition). I would like to only accept answers that include at least 3 periods (to reflect 3 sentences). I believe the language is JavaScript.

I have tried the following code \b[^.!?]+[.!?]+ \b[^.!?]+[.!?]+ \b[^.!?]+[.!?]+

It works well if the text is all in 1 line. But, I want to allow text entries to be written as three different lines.

The replies could be:

This is sentence 1. This is sentence 2. This is sentence 3.

OR

This is sentence 1.

This is sentence 2.

This is sentence 3.

I have tried working out different conditions on https://regex101.com/r/qwIVsS/1, but did not find a way to allow line breaks.

Any suggestions? Thank you!



Solution 1:[1]

To match a string if it contains at least three periods, and which may contain line breaks, you could use for example:

(?:[^.]*\.){3}[\s\S]*

See regex101.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MikeM