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

The Archive Base Latest Questions

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

i would like to escape the backslash in swipl when using string_concat. Scenario 1-

  • 0

i would like to escape the backslash in swipl when using string_concat.

Scenario 1-

string_concat('stack', ' overflow', Result).
Result = "stack overflow" 

Scenario 2-

string_concat('stack', ' \=overflow', Result).
Syntax error: Undefined character escape in quoted atom or string: `\='

Scenario 3-

string_concat('stack', ' \\=overflow', Result).
Result = "stack \\=overflow" 

Now, scenario1 behaves as expected. I am faced with a situation explained in scenario2, where in i need to concatenate a string that contains a backslash and equalto. ie, string1 has just text, string2 has text with \= also inside it, and my result should be string1 and string2 concatenated. However, using just \= as in scenario2 results in an error asking me to escape the sequence. Now, escaping as in scenario3 gives me two backslashes and the equal sign. I do not want two backslashes.

My output should be exactly stack \=overflow. Is there some escape sequence or method that I am missing here?

Thanks!

  • 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-11T15:28:02+00:00Added an answer on June 11, 2026 at 3:28 pm

    Double backslash are there just for display:

    ?- string_concat(stack, ' \\=overflow', X), writeln(X).
    stack \=overflow
    X = "stack \\=overflow".
    

    but you can change the behaviour using this flag:

    ?- set_prolog_flag(character_escapes,false).
    true.
    
    ?- writeln('stack \=overflow').
    stack \=overflow
    true.
    

    with default value true I get the error you report:

    ?- set_prolog_flag(character_escapes,true).
    true.
    
    ?- writeln('stack \=overflow').
    ERROR: Syntax error: Undefined character escape in quoted atom or string: `\='
    ERROR: writeln('stack \
    ERROR: ** here **
    ERROR: =overflow') . 
    

    Anyway, I think you should reset its value to default when done, or double check your SW for unwanted side effects on literals.

    HTH

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

Sidebar

Related Questions

what escape character is \u000a I would like it to be a quotation mark,
I would like to remove character | by using String#replaceAll() method. But first parameter
I would like to know how to escape phpdoc comments within a phpdoc comment.
I would like to escape a file, which I'm including following code won't escape
I would like to learn how to escape dot in GString so groovy (1.8)
I would like to replace the escape sequence from string test= \hi hello\ to
I have Url with space and would like to replace spaces with %20(escape them).
I have the following regex I would like to escape in Objective-C /\B\$((?:[0-9]+(?=[a-z])|(?![0-9\.\:\_\-]))(?:[a-z0-9]|[\_\.\-\:](?![\.\_\.\-\:]))*[a-z0-9]+)/ig; Not
I would like to escape characters in JSP pages. Which is more suitable, escapeXml
When the escape key is pressed, I would like to close a child window,

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.