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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:55:22+00:00 2026-05-20T18:55:22+00:00

I have an app where a user can input text in a textarea. I

  • 0

I have an app where a user can input text in a textarea. I then use that to match against a large block of text to extract whatever the user entered in the textarea if found.

Problem is, if that textarea includes a | pipe, the it stops at the pipe:

Example:

User Input: This is my entry, I should all be remove | thank you very kindly

Larger block of text: blah blah blah blah blah This is my entry, I should all be remove | thank you very kindly

Desired return is: blah blah blah blah blah

But what I get back is:

bad: blah blah blah blah blah | thank you very kindly

The regex works like so:

desired = larger_block_of_text.sub(/#{user_input}/m, '').strip

Ideas? Thank you

  • 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-05-20T18:55:23+00:00Added an answer on May 20, 2026 at 6:55 pm

    You can use Regexp.quote(user_input) to escape the special characters in the regular expression so that they are treated literally.

    Note: If you just want to find a constant string you don’t need regular expressions. You can instead use a String instead of a regular expression as the argument to sub.

    desired = larger_block_of_text.sub(user_input, '').strip
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page which displays a form that a logged-in user can use
Background I have a web app that will create an image from user input.
I have an app that lets the user search over a number of fields
I have a multi-user ASP.NET app running against SQL Server and want to have
I have been support a web app that is used by a user base
I have made a little app for signing up for an event. User input
In my web app, users can input text data. This data can be shown
I have an app which could benefit from the user being able to choose
Hey all - I have an app where I'm authenticating the user. They pass
I'm working on a WinForms app and I have a user control in it.

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.