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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:04:35+00:00 2026-05-28T06:04:35+00:00

I have a regex problem which bugs me and have no clue how to

  • 0

I have a regex problem which bugs me and have no clue how to solve it.

I have an input field with a text and I like to extract certain values out of it.
I would like to extract a title, description, a price and a special price.

Examples for the input:

  • everything what is plain text is concerned as title.
  • everything within within hashes (#description goes here#) is considered the description.
  • $23.49 is considered as price and %$19.99 would match the special price.

The CoffeeScript pattern I’m using:

 pattern = ///
  ([^$]+)
  (#(.+?)#+)
  ([\$]\d+\. \d+)
  ([\%\$]\d+\. \d+)
  ///
  params = [title,description,oldPrice,newPrice]=input_txt.match(pattern)[1..4]

It does not work. It should work if I enter all values in the given sequence and I also have to provide a the asked substring.

What I would like to have is the ability to extract the sequments if the are provided (so optional) and no matter of the sequence…
How can I extract optional sequences of an string…
EDIT///
I provide some examples

exmp1:

Kindle #Amazon's ebook reader# $79.00

this should be extracted as

title:Kindle 
description: Amazon's ebook reader 
oldPrice:$79.00

exmp2:

Nike Sneaker's $109.00 %$89.00

this should be extracted as

title:Nikes Sneaker's 
oldPrice:$109.00 
newPrice:$89.00

exmp3:

$100.00 Just dance 3 #for XBox# 

this should be extracted to

title: Just dance 3 
description: for XBox 
oldPrice:$100.00

Any help would be great …

  • 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-28T06:04:36+00:00Added an answer on May 28, 2026 at 6:04 am

    The nature of regular grammars makes it hard to solve your problem. As a work around the simplest solution would be to just execute your regex 4 times:

    1. Match /#(.+?)#+/ and remove the result string (string replace) from the original
    2. Match /[\%\$]\d+. \d+/ and remove the result string from the original
    3. Match /[\$]\d+. \d+/ and… you get the pattern
    4. Now what remains in the original is the the title.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an input like this test1.test2.part01 which I want to strip away to
I have the following regex ^[a-zA-Z0-9]+$ which would allow alpha numeric characters. The problem
i have a very strange problem which i cannot solve at the moment. i
Possible Duplicate: Java - Regex problem I have list of URLs of types: http://www.example.com/pk/etc
While doing some small regex task I came upon this problem. I have a
I'm trying to get a regexp to solve the next problem: I have some
I have a simple problem: I want to construct a regex that matches a
I have this homework problem where I need to use regex to remove every
I have a rather simple C++ project, which uses boost::regex library. The output I'm
I have articles on my website which I would like to get corrected and

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.