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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:09:17+00:00 2026-06-12T09:09:17+00:00

I wish to replace all instances of a pipe in a specific string with

  • 0

I wish to replace all instances of a pipe in a specific string with something else. However, not only is it not replacing the specified string but instead replacing all blank spaces. Example:

String cleanTitle = StringEscapeUtils.escapeHtml("Bacon is | good");
out.println(cleanTitle.replaceAll("|", "*"))

This example is outputting *B*a*c*o*n*i*s*|*g*o*o*d*

I need it to say Bacon is * good

-The function escapeHTML is necessary for my interface, despite this example not using it for my question.

  • 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-12T09:09:18+00:00Added an answer on June 12, 2026 at 9:09 am

    You need to escape the pipe in your expression, so use:

    cleanTitle.replaceAll("\\|", "*")
    

    See also

    • http://www.regular-expressions.info/characters.html
    • http://www.regular-expressions.info/alternation.html
    • http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wish to replace spaces in something like this: <span>5</span>SPACE<image href=mtgsymbol.png /> but when
I wish to replace all the link urls in some HTML with a number
I wish to do a search and replace in a string. It searches for
Given test<-Low-Decarie, Etienne I wish to replace all punctuation with space gsub(pattern=[:punct:], x=test, replacement=
$data contains tabs, leading spaces and multiple spaces. I wish to replace all tabs
I wish to replace all the backslashes (which appear on the same line with
I am using preg_replace($oldWords, $newWords, $string); to replace an array of words. I wish
During the table echo how would I replace all digits using regex? I wish
I have a WordPress blog with numerous URL's I wish to replace from this:
I am writing an XSLT transformation in which I wish to use the Replace

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.