Get last part of url using a regex

java, regex, solr

Solution

how about:

".*/([^/#]*)(#.*|$)"

Problem

How do I get the last part of the a URL using a regex, here is my URL, I want the segmeent between the last forward slash and the # ``` http://mycompany.com/test/id/1234#this ``` So I only want to get `1234`. I have the following but is not removing the '#this' ``` ".*/(.*)(#|$)", ``` I need this while indexing data so don't want to use the URL class.

Original source