-5

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
  • 9,648
  • 9
  • 21
  • 34
vardius
  • 5,589
  • 6
  • 47
  • 84

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
  • 297,146
  • 54
  • 452
  • 522
Rahul Tripathi
  • 152,732
  • 28
  • 233
  • 299