-3

I'm not good with RegEx and I would like have a RegEx for next URL scheme.

Can you help me to create a regular expression for that URL?

https://fonts/mapbox/{fontstack}/{range}.pbf

And if possible, show me one page to learn and understand it.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Javier
  • 1,975
  • 3
  • 24
  • 46
  • see this https://stackoverflow.com/questions/4736/learning-regular-expressions – Salman Saleem Jan 11 '19 at 12:01
  • I solved with this regex. let expression = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&\/=]*){fontstack}\/{range}.pbf/gi; – Javier Jan 11 '19 at 12:42

1 Answers1

1

The best page I use to explain RegEx is https://regex101.com/.

In case your characters are all word characters, you can just use:

https://fonts/mapbox/(\w+)/(\w+).pbf

In the first group you will have "fontstack" and in the second you will have "range".

If you want to include a bit more of possible characters, maybe:

https://fonts/mapbox/([^\s\/])/([^\s\/]).pbf

You can see extensive explanations to both introducing them on the page I provided at the start.

dquijada
  • 1,697
  • 3
  • 14
  • 19
  • thanks :D the idea is 'https://' required + [n * anything text with / ] + \.[a-z]{2,6} + [n * anything text with / ] + '{fontstack]/{range}.pbf – Javier Jan 11 '19 at 12:33