Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Titles start with quotation mark #3

Closed
nikolaos83 opened this issue Feb 16, 2024 · 1 comment · Fixed by #4
Closed

Titles start with quotation mark #3

nikolaos83 opened this issue Feb 16, 2024 · 1 comment · Fixed by #4

Comments

@nikolaos83
Copy link

Almost all the titles that come out of this script start with a quotation mark. Copilot has this to say about it. IDK, because I'm just learning JS but maybe you should have a look at it.

"The issue seems to be with the regular expression used in the replace() function. The regular expression ^\d+[.)]\s+"|"$ is looking for a digit at the start of the string followed by a period or a parenthesis, then one or more spaces, and then a quotation mark. It also looks for a quotation mark at the end of the string. However, the | operator in the regular expression is causing the issue. It creates two separate conditions: one for the start of the string and one for the end of the string.

Here’s the corrected function:

function cleanTitle(title) {
  // Remove numbering (e.g. 1., 2., 1), 2)) and wrapping quotes
  return title.replace(/^\d+[\.)]\s+\"|\"$/g, '').replace(/^\"|\"$/g, '').trim();
}

In this corrected function, I’ve added another replace() function with the regular expression ^"|"$. This regular expression looks for a quotation mark at the start or end of the string and replaces it with nothing. This should remove the quotation marks at the start and end of your titles. If you have any more questions or need further clarification, feel free to ask! 😊"

@betschki
Copy link
Owner

@nikolaos83 thank you for reporting this and #2 – i have improved the title cleaning and just merged the changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants