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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:48:24+00:00 2026-06-08T13:48:24+00:00

I’m trying to write a search engine bookmarklet (for Chrome), but I’m having trouble

  • 0

I’m trying to write a search engine bookmarklet (for Chrome), but I’m having trouble escaping the string.

For example if the search engine bookmarklet is the following:

javascript:alert("%s"); //%s is the search engine query, passed literally by chrome.

Then running it on the following string will give incorrect results:

c:\zebra

c:zebra instead of c:\zebra

If the character after the slash happens to be an actual escape character, then the results will vary depending on the character.

I’ve tried escaping and unescaping the string, I’ve tried reg-ex’ing it, and replacing the slash with a double-slash, but I cannot figure out a way to get this to work because the first time that the raw string enters the script, it is unescaped, and any operation after that will see it incorrectly.

How can this be handled correctly?

  • 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-08T13:48:29+00:00Added an answer on June 8, 2026 at 1:48 pm

    So far I can only make this work in chrome:

    javascript: var str = (function(){STARTOFSTRING:/*%s*/ENDOFSTRING:;}).toString().match( /STARTOFSTRING:\/\*([\s\S]*)\*\/ENDOFSTRING:/ )[1]; alert(str);
    

    writing c:\zebra will alert c:\zebra.

    Firefox doesn’t sustain the comments inside the function body when decompiled, unfortunately.

    You also can’t write the sequence */ in the string, but everything else should be passed literally, including quotes " ' etc

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

Sidebar

Related Questions

I am trying to write a quick search that searches a List<String> Instead of
I'm trying to write a search script for my website. And i'm having two
I am trying to write a lucene search in an Alfresco webscript (javascript) to
I am trying to write a regex in Ruby to search a string for
im trying to write a code that should allow me to search a string
I am trying to write a query to search a subclass attribute that is
I'm trying to write an SQL query that would search within a CSV (or
I'm trying to write a query for the find-as-you-type search bar. What I want
I am trying to write a bash script(script.sh) to search and replace some variables
Possible Duplicate: byte[] array pattern search I am trying to write a simple compression

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.