Regex to match non-empty string

Viewed 30

Im trying to make preg_match_all regex that will work in next order. Group 1 to match "Example", Group 2 to match "[string]", Group 3 to match whitespace and "Number" and Group 4 to match "[int]". If the string is empty the regex should be false.

$string = Example[string] Number[int]

I have tried something with this https://regex101.com/r/MdWNCT/1, but no luck so far. Can anyone suggest me what to do?

Thank you.

1 Answers

Does this work for you?

^(?!\s*$).+

Related