Regular expression query, data from a url

0

I have these URLs

veiculos-sao-paulo-__4--6--.html
veiculos-parana__4--6--.html
veiculos-rio-de-janeiro-__4--6--.html

With this regular expression:

^veiculos-([a-zA-Z-]+)__.+\.html?

I get the group $ 1 with the following outputs:

  

sao-paulo-

     

parana

     

rio-de-janeiro -

I would like to not receive the hyphen "-" from the end.

How could I adapt my regex to not catch the hyphen, considering that it may or may not come at the end of the url?

desired output:

  

sao-paulo

     

parana

     

rio-de-janeiro

    
asked by anonymous 14.08.2017 / 22:22

1 answer

0

Regular expression: .*?-(.+?)-?_.*

Test: link

    
14.08.2017 / 22:39