DrByte:
Your proposed new regex looks overly complicated. Can you explain it in english?
First... thanks for moving this, I wasn't sure where to place and didn't really wont to post in full view.
I'm still learning Regex strings and after looking closer at this I think it could be simplified.. Line was getting created as spam came in.. I was capturing spam while testing using the logging system.
This was created using regex101(DOT)com to help explain it.. wrap in code to keep from sanitizing it.
----- Match Information ------
http://www.mysite.com
Match 1
Full match 0-21 http://www.mysite.com
Group 1. 0-21 http://www.mysite.com
Group 2. 0-7 http://
https://www.mysite.com
Match 1
Full match 0-22 https://www.mysite.com
Group 1. 0-22 https://www.mysite.com
Group 2. 0-8 https://
mysite DOT com
Match 1
Full match 7-11 DOT
Group 1. 7-11 DOT
mysite(DOT)com
Match 1
Full match 7-11 DOT)
Group 1. 7-11 DOT)
www.mysite.com
Match 1
Full match 0-14 www.mysite.com
Group 1. 0-14 www.mysite.com
mailto:[email protected]
Match 1
Full match 0-26 mailto:[email protected]
Group 1. 0-26 mailto:[email protected]
Group 2. 0-7 mailto:
[email protected]
Match 1
Full match 0-19 [email protected]
Group 1. 0-19 [email protected]
www.url-with-querystring.com/?url=has-querystring
Match 1
Full match 0-28 www.url-with-querystring.com
Group 1. 0-28 www.url-with-querystring.com
------ Full Explanation ---------
1st Capturing Group (([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+|(?:DOT\W)+)
1st Alternative ([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+
2nd Capturing Group ([A-Za-z]{3,9}:(?:\/\/)?)
Match a single character present in the list below [A-Za-z]{3,9}
{3,9} Quantifier — Matches between 3 and 9 times, as many times as possible, giving back as needed (greedy)
A-Z a single character in the range between A (index 65) and Z (index 90) (case sensitive)
a-z a single character in the range between a (index 97) and z (index 122) (case sensitive)
: matches the character : literally (case sensitive)
Non-capturing group (?:\/\/)?
? Quantifier — Matches between zero and one times, as many times as possible, giving back as needed (greedy)
\/ matches the character / literally (case sensitive)
\/ matches the character / literally (case sensitive)
Non-capturing group (?:[-;:&=\+\$,\w]+@)?
? Quantifier — Matches between zero and one times, as many times as possible, giving back as needed (greedy)
Match a single character present in the list below [-;:&=\+\$,\w]+
+ Quantifier — Matches between one and unlimited times, as many times as possible, giving back as needed (greedy)
-;:&= matches a single character in the list -;:&= (case sensitive)
\+ matches the character + literally (case sensitive)
\$ matches the character $ literally (case sensitive)
, matches the character , literally (case sensitive)
\w matches any word character (equal to [a-zA-Z0-9_])
@ matches the character @ literally (case sensitive)
Match a single character present in the list below [A-Za-z0-9.-]+
+ Quantifier — Matches between one and unlimited times, as many times as possible, giving back as needed (greedy)
A-Z a single character in the range between A (index 65) and Z (index 90) (case sensitive)
a-z a single character in the range between a (index 97) and z (index 122) (case sensitive)
0-9 a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
.- matches a single character in the list .- (case sensitive)
2nd Alternative (?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+
Non-capturing group (?:www.|[-;:&=\+\$,\w]+@)
1st Alternative www.
www matches the characters www literally (case sensitive)
. matches any character (except for line terminators)
2nd Alternative [-;:&=\+\$,\w]+@
Match a single character present in the list below [-;:&=\+\$,\w]+
+ Quantifier — Matches between one and unlimited times, as many times as possible, giving back as needed (greedy)
-;:&= matches a single character in the list -;:&= (case sensitive)
\+ matches the character + literally (case sensitive)
\$ matches the character $ literally (case sensitive)
, matches the character , literally (case sensitive)
\w matches any word character (equal to [a-zA-Z0-9_])
@ matches the character @ literally (case sensitive)
Match a single character present in the list below [A-Za-z0-9.-]+
+ Quantifier — Matches between one and unlimited times, as many times as possible, giving back as needed (greedy)
A-Z a single character in the range between A (index 65) and Z (index 90) (case sensitive)
a-z a single character in the range between a (index 97) and z (index 122) (case sensitive)
0-9 a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
.- matches a single character in the list .- (case sensitive)
3rd Alternative (?:DOT\W)+
Non-capturing group (?:DOT\W)+
+ Quantifier — Matches between one and unlimited times, as many times as possible, giving back as needed (greedy)
DOT matches the characters DOT literally (case sensitive)
\W matches any non-word character (equal to [^a-zA-Z0-9_])