I’m sure there might be something simular on stack overflow but I can’t find anything and am getting quite frustrated with what should be very simple.
I need to capture part of a url (similar to a url rewriting engine) using javascript.
URL structure:
http://example.com/constant/CAPTURETHIS
http://example.com/constant/CAPTURETHIS/
http://example.com/constant/CAPTURETHIS#noise
http://example.com/constant/CAPTURETHIS/#noise
I need to just return the CAPTURETHIS text for all 3 senerios
JavaScript supports the retrieval of regex capture-groups by using a string object’s
matchmethod or a regular-expression object’sexecmethod:But for your example, I almost wonder if it’s simpler to use the string object’s
splitmethod: