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

  • Home
  • SEARCH
  • 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 8677489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:28:11+00:00 2026-06-12T20:28:11+00:00

What I am trying to do is write a script in Matlab that will

  • 0

What I am trying to do is write a script in Matlab that will parse some HTML, get some data out of it, take this data, and then format it into a Javascript string array. I do not have a problem grabbing HTML and parsing it and so forth, I am having trouble trying to print a string using sprintf that will contain a backslash.

Basically if you have a string in Javascript that contains a quotation mark you need to escape it with a backslash:

var string1 = "Here is a \"string\" example";

When I try to do this in Matlab as follows, it does not print correctly:

>> A = sprintf('Here is a \"string\" example')
A =
    Here is a "string" example

This is not a valid Javascript string. So basically I want sprintf to return a proper Javascript string; any suggestions?

I have tried using \\" and \\\" and a few similar combinations, all to no avail.

  • 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-12T20:28:12+00:00Added an answer on June 12, 2026 at 8:28 pm

    Matlab uses the reference Kernighan, B. W., and D. M. Ritchie, The C Programming Language for its sprintf function. According to the reference, the way sprintf is defined, it uses escape character as a way to overcome the default control meaning of characters.

    Although you asked not to suggest the combination like

    \"
    
    \\\"
    

    here is the viable solution where you don’t have to manually replace the \” with \\” and the code does this action itself.

    a = "Here is a \"string\" example";
    d = regexprep(a,"\"","\\\"");
    sprintf(d);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to write a script that will get a user's geolocation - if
I am trying to write a script that will parse a local file and
I am trying to write MSBuild script that will perform some action (eg. print
I am trying to write a script that will parse a directory, find the
I'm trying to write a script that will automatically update some attachments on a
I'm trying to write a script that stores some data chunks inside flat .txt
I'm trying to write a script that will help me map some old users
I'm trying to write a script with wsadmin that will retrieve the total amount
I'm trying to write a script that will create a user in MediaWiki, so
I'm trying to write a script that will download files from an FTP server.

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.