javascript - What RegEx would clean up this set of inputs? -


i'm trying figure out regex match following:

.../string-with-no-spaces -> string-with-no-spaces

or

string-with-no-spaces:... -> string-with-no-spaces

or

.../string-with-no-spaces:... -> string-with-no-spaces

where ... can in these example strings:

example.com:8080/string-with-no-spaces:latest string-with-no-spaces:latest example.com:8080/string-with-no-spaces string-with-no-spaces 

and bonus be

http://example.com:8080/string-with-no-spaces:latest 

and match string-with-no-spaces.

is possible single regex cover cases?

so far i've gotten far /\/.+(?=:)/ not includes slash, works case 3. ideas?

edit: should mention i'm using node.js, ideally solution should pass of these: https://jsfiddle.net/ys0znlef/

how about:

(?:.*/)?([^/:\s]+)(?::.*|$) 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -