DEV Community


Discussion on: Need help cleaning up this code, which modifies the subdomain.

kspeakman profile image
Kasey Speakman • Edited
var subdomainMatch = /^[^.]+\./;
var admin =, "admin.");

This is using a regex, but at least it is a small one.

op meaning
^ line starts with
[^ any character except the following
. the character .
] end of character list
+ match one or more of the preceding (any character except .)
\. match the character .
dechamp profile image
DeChamp Author • Edited

gorgeous! I love me some regex. I was trying to do this yesterday but going about it all wrong. I was trying to abstract out the last part of the domain. Should have made it easy on myself and just find/replace the subdomain! Thank you!