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 6368171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:38:30+00:00 2026-05-25T00:38:30+00:00

I am trying to read a bibtex file into my JavaScript script. The Regex

  • 0

I am trying to read a bibtex file into my JavaScript script.
The Regex used to parse the file is:

/(.*)\s*=\s*[{"'](.*|.*\s+.*|.*\s+.*\s+.*|.*\s+.*\s+.*\s+.*|.*\s+.*\s+.*\s+.*\s+.*)[}"'],?/g

This works as I want it to:

@Article{journals/aim/Sloman99,
  title =   "Review of Affective Computing",
  author =  "Aaron Sloman",
  journal = "AI Magazine",
  year =    "1999",
  number =  "1",
  volume =  "20",
  url = "http://dblp.uni-trier.de/db/journals/aim/aim20.html#Sloman99",
  pages =   "127--133",
}

It gives me nice key.value pairs like: “author : Aaron Sloman”.

This doesn’t:

@Article{journals/aim/Sloman99,
  title =   "Review of Affective Computing",
  author =  "Aaron
  S
  l
  o
  m
  a
  n",
  journal = "AI Magazine",
  year =    "1999",
  number =  "1",
  volume =  "20",
  url = "http://dblp.uni-trier.de/db/journals/aim/aim20.html#Sloman99",
  pages =   "127--133",
}

It just omits the author.

So how can I make a regex that matches an entry with as much newlines (not only as much as there are repetitions of “.*\s+”) as there are till it encounters a ” or a }?

  • 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-05-25T00:38:30+00:00Added an answer on May 25, 2026 at 12:38 am

    I know people love to use regular expressions to parse markup, it seems to be a fad… like lady gaga, or the Fun Dip. But if you want to parse mark up efficentially you should use a parser or write one.

    Why, Regular expressions is meant to parse regular language. Most markdowns cannot be expressed as an NFA or DFA. And because of this using regex to parse them is… impossible at the hardest point, and just slow at the easiest.

    There are a couple great JS bibtex parsers out there

    • http://sourceforge.net/projects/jsbibtex/
    • http://code.google.com/p/bibtex-js/

    are two, I recommend you look at those… I know you have already done work to create your regular expression but I promise your job will become much easier when you take the step to a real parser.

    Just a small example of why your regex is bad and a parser is better.

    Matching patterns include

    ;;;)(>$#@ = 'dfsa3 342 '}
    ((())))+++>$#@ = 'dfsa3@@//''''''''''''
    >$#@ = 'dfsa3@@//'''}}}}"""
    

    These are not good!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to read a .doc file into a database so that I can
Trying to read into an object the following XML file (can be changed) into
Im trying to read a text file, x bytes at a time into a
Im trying to read and write to/from the same file, is this possible? Here
Im trying to read some data from a binary file into a buffer allocated
I'm trying to read-in a bunch of unsigned integers from a configuration file into
I'm trying to read a .java file into a JTextArea and no matter what
I'm trying to read this .dat file and then add the content to a
Trying to read headers for a csv file with: reader = csv.DictReader(open(PATH_FILE),skipinitialspace=True) headers =
I'm currently trying to read in an XML file, make some minor changes (alter

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.