Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8239781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:15:44+00:00 2026-06-07T20:15:44+00:00

im trying to parse a javascript file to return font-face urls. the file look

  • 0

im trying to parse a javascript file to return font-face urls.

the file look like this

@font-face {
  font-family: 'AlfaSlab';
  iesrc: url('/lib/assets/themes/ek/skins/default/alfaslabone-regular-webfont.eot');
  url('/lib/assets/themes/ek/skins/default/alfaslabone-regular-webfont.woff')

i want to grab all font links with file extensions (eot,woff,svg,otf)

i came up with this regex /(\/lib\/.*?\/.*?\.(eot|woff|ttf|svg))/ but its returning also the file extensions (because the () in the file extensions)

in ruby im doing this files.map {|file| File.read(file).scan(regex)} #=> ['/lib/assets/themes/ek/skins/default/alfaslabone-regular-webfont.eot','eot','/lib/assets/themes/ek/skins/default/alfaslabone-regular-webfont.woff','woff']

how can i fix the regex to only return the file path instead of the file path + file extension in 2 array elements, thanks 🙂

EDIT:

i want to return the whole path with the file extension, ['/lib/assets/themes/ek/skins/default/alfaslabone-regular-webfont.eot','/lib/assets/themes/ek/skins/default/alfaslabone-regular-webfont.woff'] should be the match.. thanks for your time

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T20:15:46+00:00Added an answer on June 7, 2026 at 8:15 pm

    You can rewrite your regex:

    /([\w\-\/]+\.(?:eot|woff|ttf|svg))/
    
    • [\w\-\/] defines a set of characters:
      • \w word character, i.e. letter (a-z, A-Z), number (0-9) and underscore (_)
      • \- hyphen (-)
      • \/ slash (/)
    • + means one or more of these characters
    • \. is the dot before the file extension
    • (eot|woff|ttf|svg) is the file extension
    • ?: tells the regex engine to not generate a backreference for this capturing group
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to parse apart a string like this with javascript: var mystr =
I'm trying to fetch and parse an XML-file through JavaScript. I don't control the
I am trying to parse an HTML file ( non strict one) using JavaScript
I'm trying to parse Reddit's XML file with javascript and im having trouble retrieving
I am trying to parse a large XML file using JavaScript. Looking online, it
I'm trying to parse a simple JSON file. I'm very new to javascript, JSON,
I'm trying to parse a simple JSON file. I'm very new to javascript, JSON,
Something's screwy here. I'm trying to parse this XSL file: <?xml version=1.0 encoding=utf-8?> <xsl:stylesheet
I am trying to parse the following XML with javascript: <?xml version='1.0' encoding='UTF-8'?> <ResultSet>
I'm trying parse the follow XML file: <root>Root <pai>Pai_1 <filho>Pai1,Filho1</filho> <filho>Pai1,Filho2</filho> </pai> <pai>Pai_2 <filho>Pai2,Filho1</filho>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.