-4

Can someone please explain what this regexp matches?

#\b(https://exampleurl.com/)([^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))#

I have no experience with regexp and I need to know what this one does.

VMai
  • 10,156
  • 9
  • 25
  • 34
vardius
  • 6,326
  • 8
  • 52
  • 97

1 Answers1

1

Trying with link. It explains all:

/[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|))/

[^\s()<>]+ match a single character not present in the list below

Quantifier: Between one and unlimited times, as many times as possible, giving back as needed [greedy]

\s match any white space character [\r\n\t\f ]

()<> a single character in the list ()<> literally (case sensitive)

(?:([\w\d]+)|([^[:punct:]\s]|)) Non-capturing group

1st Alternative: ([\w\d]+)

\( matches the character ( literally

[\w\d]+ match a single character present in the list below

Quantifier: Between one and unlimited times, as many times as possible, giving back as needed [greedy]

\w match any word character [a-zA-Z0-9_]

\d match a digit [0-9]

\) matches the character ) literally

2nd Alternative: ([^[:punct:]\s]|)

1st Capturing group ([^[:punct:]\s]|)

1st Alternative: [^[:punct:]\s]

[^[:punct:]\s] match a single character not present in the list below

[:punct:] matches punctuation characters [POSIX]

\s match any white space character [\r\n\t\f ]

2nd Alternative: ([^[:punct:]\s]|)

1st Capturing group ([^[:punct:]\s]|)

1st Alternative: [^[:punct:]\s]

[^[:punct:]\s] match a single character not present in the list below

[:punct:] matches punctuation characters [POSIX]

\s match any white space character [\r\n\t\f ]

2nd Alternative: (null, matches any position)

Tim Pietzcker
  • 328,213
  • 58
  • 503
  • 561
Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331