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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:46:05+00:00 2026-05-16T18:46:05+00:00

I want to process a String, in which I want to find multiple strings,

  • 0

I want to process a String, in which I want to find multiple strings, i am trying to make some highlighter in html text in java..
Example:
Find and process phrases table, row, primary key in Each table row contains a primary key column
The text is html text with tags like <b>,<img..>...
if there is ignorable tag in the middle of phrase for ex. primary <b>key</b>(ignorable tag is the tag that does not interrupt the text meaning like <b> or <i>, on the other hand tag like <div> interrupts the text meaning) the phrase can be replaced.
if one phrase is a subphrase of other phrase, the longer has a higher priority. for ex. searching for table row and row contains in the mentioned text the second one should be proccesed

My first pseudocode was somethin like this:

for (each phrase)  
  while(tex.hasNext(phrase)) do
    processPhraseInText(text,phrase)
  end-while
end-for

It was working, but the text was traversed phrases.count() times and I am searching a faster way to process all the prases at once

I want to try the Regular expression and pattern-matcher to use in this.
I came up with two ways, 1. create one regular expression for all the phrases looking somehow like this: regex1|regex2|..|regexN or 2. to create for every phrase one regex( and one Matcher object)

what could be the better way? or is there some totaly different way or existing library for this? isnt the second way with many matchers the same like the sollution I already have?

  • 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-16T18:46:06+00:00Added an answer on May 16, 2026 at 6:46 pm

    If you make a regex for each phrase, you still have to loop over the text a couple of times.

    If you make one regex regex1|regex2|..|regexN, you can search through the text in one pass.
    This would be faster with many phrases.

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

Sidebar

Related Questions

I want to do some benchmarking of a C# process, but I don't want
I am trying to create an iPhone application which in some point connects to
I want to process each source code file after it has been preprocessed: myprocess
I want to spawn another process to display an error message asynchronously while the
I want to run a weekly batch process in an asp.net page. How can
I want to upload and then process a file in a Ruby on Rails
I want to kill a whole process tree. What is the best way to
I want to wait for a process to finish, but Process.WaitForExit() hangs my GUI.
I want to obtain maximum performance out of a process with many variables, many
I want to automate a Windows 2000+ server reboot process using Task Scheduler or

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.