- Save Regexctrl+s
- Go to library entry

- PCRE2 (PHP >=7.3)
- PCRE (PHP <7.3)
- ECMAScript (JavaScript)
- Python
- Golang
- Java 8

- Match
- Substitution
- List
- Unit Tests

Sponsor

Jamstack at Scale

"

(^ *\S+ *$)|(^ *(\S+ ){1,3}\S+ *$)|(^ *(\S+ ){5,}\S+ *$)|(^ +(\S+ ){4}\S+ +$)

"

mg

1st Alternative

(^ *\S+ *$)

1st Capturing Group

(^ *\S+ *$)

^ asserts position at start of a line

\S

matches any non-whitespace character (equivalent to [^\r\n\t\f\v ])+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)

$ asserts position at the end of a line

2nd Alternative

(^ *(\S+ ){1,3}\S+ *$)

2nd Capturing Group

(^ *(\S+ ){1,3}\S+ *$)

^ asserts position at start of a line

3rd Capturing Group

(\S+ ){1,3}

{1,3} matches the previous token between 1 and 3 times, as many times as possible, giving back as needed (greedy)

A repeated capturing group will only capture the last iteration. Put a capturing group around the repeated group to capture all iterations or use a non-capturing group instead if you're not interested in the data

\S

matches any non-whitespace character (equivalent to [^\r\n\t\f\v ])+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)

matches the character with index 32_{10} (20_{16} or 40_{8}) literally (case sensitive)

\S

matches any non-whitespace character (equivalent to [^\r\n\t\f\v ])+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)

$ asserts position at the end of a line

3rd Alternative

(^ *(\S+ ){5,}\S+ *$)

4th Capturing Group

(^ *(\S+ ){5,}\S+ *$)

^ asserts position at start of a line

5th Capturing Group

(\S+ ){5,}

{5,} matches the previous token between 5 and unlimited times, as many times as possible, giving back as needed (greedy)

A repeated capturing group will only capture the last iteration. Put a capturing group around the repeated group to capture all iterations or use a non-capturing group instead if you're not interested in the data

\S

matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) matches the character with index 32_{10} (20_{16} or 40_{8}) literally (case sensitive)

\S

matches any non-whitespace character (equivalent to [^\r\n\t\f\v ])$ asserts position at the end of a line

4th Alternative

(^ +(\S+ ){4}\S+ +$)

6th Capturing Group

(^ +(\S+ ){4}\S+ +$)

^ asserts position at start of a line

7th Capturing Group

(\S+ ){4}

{4} matches the previous token exactly 4 times

A repeated capturing group will only capture the last iteration. Put a capturing group around the repeated group to capture all iterations or use a non-capturing group instead if you're not interested in the data

\S

matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) matches the character with index 32_{10} (20_{16} or 40_{8}) literally (case sensitive)

\S

matches any non-whitespace character (equivalent to [^\r\n\t\f\v ])$ asserts position at the end of a line

Global pattern flags

m modifier: **m**ulti line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)

g modifier: **g**lobal. All matches (don't return after first match)

Your regular expression does not match the subject string.

No Match

r"

"

mg

Please wait while the app is loading...