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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:02:21+00:00 2026-05-24T05:02:21+00:00

I need help in constructing RegEx for the search function on my website. I

  • 0

I need help in constructing RegEx for the search function on my website. I am currently using JQuery framework. The goal is to go through paragraphs in XML and returns node that contains keywords inserted in the search text field.

For example, user may enter “Lorem Sed Pellentesque” in the search text field and I would like to use the keywords enter in the text field and go through the paragraph and find these keywords no matter the position of the keywords. Below is the sample of the paragraph:

Nullam accumsan leo ultrices nisi consectetur blandit. Integer
aliquam, urna nec vestibulum posuere, est ante sollicitudin tortor,
non feugiat eros orci vitae dui. In lacus nulla, feugiat vitae porta
vel, lobortis eget ligula. Sed egestas aliquet orci ut varius.
Pellentesque ullamcorper magna eu sem convallis elementum.

So in this case, this paragraph will be considered as one of the results since it contains “Sed” and “Pellentesque” keywords.

Is it possible to construct RegEx that can go through the whole paragraph? It does not matter if it is case-sensitive or not.

Any help is really appreciated! Thank you in advance.

  • 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-24T05:02:22+00:00Added an answer on May 24, 2026 at 5:02 am

    Something like this (not very robust but will work for alphanumeric keywords):

    var keywords = $('input').text().replace(" ", "|");
    var re = new RegExp(keywords, "gi"); // make it global, case insensitive
    var matches = re.exec("paraText");
    

    Although, you can do it without regex:

    var keywords = $('input').text().split();
    $(keywords).each(function() {
      if(paraText.indexOf(this) > 0) {
        // keyword found
      }
    });
    

    If you want to match between word boundaries, you need some regex like this:

    var keywords = $('input').text().split();
    $(keywords).each(function() {
      var re = new RegExp("\\b" + this + "\\b");
      if(re.test(paraText)) {
        // keyword found
      }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need help writing a script downloads data from google insight using c# this is
i need help with disk_total_space function.. i have this on my code <?php $sql=select
I need help on regex or preg_match because I am not that experienced yet
I need help constructing a CodeIgniter Datamapper ORM query that includes join fields. I
I need help constructing a monitor that implements a semaphore, and simple C example
I'm having quite a hard time on constructing my 1st XML Schema. I need
I need help constructing a linq query that will return a list of usernames
I'm new with jquery and I'm having problems in constructing functions. I need some
need help on Regex. Say I have the following text: * 1 FETCH (UID
Need help to figure out why the following code for basic Binary Search Tree

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.