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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:26:35+00:00 2026-06-04T10:26:35+00:00

How can one use the replace function in SPARQL 1.1, especially in update commands?

  • 0

How can one use the replace function in SPARQL 1.1, especially in update commands?

For example, if I have a number of triples ?s ?p ?o where ?o is a string and for all triples where ?o contains the string “gotit” I want to insert an additional triple where “gotit” is replaced by “haveit”, how could I do this? I am trying to achieve this is Sesame 2.6.0.

I tried this naive approach:

INSERT { ?s ?p replace(?o,"gotit","haveit","i") . }
WHERE { ?s ?p ?o . FILTER(regex(?o,"gotit","i")) }

but this caused a syntax error.

I also failed to use replace in the result list of a query like so:

SELECT ?s ?p (replace(?o,"gotit","haveit","i") as ?r) WHERE { .... }

The SPARQL document unfortunately does not contain an example of how to use this function.

Is it possible at all to use functions to create new values and not just test existing values and if yes, how?

  • 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-04T10:26:37+00:00Added an answer on June 4, 2026 at 10:26 am

    You can’t use an expression directly in your INSERT clause like you have attempted to do. Also you are binding ?name with the first triple pattern but then filtering on ?o in the FILTER which is not going to give you any results (filtering on an unbound variable will give you no results for most filter expressions).

    Instead you need to use a BIND in your WHERE clause to make the new version of the value available in the INSERT clause like so:

    INSERT 
    {
      ?s ?p ?o2 .
    }
    WHERE 
    { 
      ?s ?p ?o .
      FILTER(REGEX(?o, "gotit", "i"))
      BIND(REPLACE(?o, "gotit", "haveit", "i") AS ?o2)
    }
    

    BIND assigns the result of an expression to a new variable so you can use that value elsewhere in your query/update.

    The relevant part of the SPARQL specification you are interested in is the section on Assignment

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

Sidebar

Related Questions

what can I use to replace the string if its in the following format
How can one use Triggers for Logging History of database changes in MySQL? If
In *nix systems one can use which to find out the full path to
In servlet 3.0 one can use startAsync to put long work in another thread,
According to man 5 proc , one can use the /proc filesystem to access
On Google App Engine to query the data store with Python, one can use
Simple question. I'm new to Clojure. How can I use one file from my
Can any one tell me how to use Silverlight to play audio from local
How can I subtract one image from another using openCV? Ps.: I coudn't use
Can I use Acer Aspire One D270 net-book for programming It has got a

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.