-2

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!

msg
  • 21
  • 5
  • It would be a lot more helpful if you could provide some sample inputs *and* their expected outputs. – Robo Mop May 12 '22 at 22:48

1 Answers1

0

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.

MikeM
  • 13,156
  • 2
  • 34
  • 47