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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:37:42+00:00 2026-06-05T18:37:42+00:00

Possible Duplicate: RegEx match open tags except XHTML self-contained tags I have a file

  • 0

Possible Duplicate:
RegEx match open tags except XHTML self-contained tags

I have a file containing about 2000 lines such as this:

<nobr>&nbsp;&nbsp;&nbsp;&nbsp;<a href="../Carbon_Monoxide_Poisoning_Prevention.htm"><b>poisoning - prevention</b></a></nobr><br>
<nobr>&nbsp;&nbsp;&nbsp;&nbsp;<a href="../Carbon_Monoxide_Symptoms.htm"><b>symptoms</b></a></nobr><br>

1.) the URL is ALWAYS in the form of ../foo.html

2.) the display name is SOMETIMES enclosed with <b> ... </b> tags, and sometimes not.

3.) each line in the file contains up to four &nbsp; that I need to count and flag as spaces. These will EVENTUALLY be used to format indents, so I need to capture the information somehow.

I need to have the hyperlink, display name and number of spaces name in a delimited flat file as follows (based on the above data):

../Carbon_Monoxide_Poisoning_Prevention.htm,poisoning - prevention,4
../Carbon_Monoxide_Symptoms.htm,symptoms,4

. While I can parse this through a whole mess of String, substring, and if statements, that seems to be more cumbersome than it needs to be. I was investigating Regex (my first time doing so), but am a little unclear on some of the syntax; I learn best seeing a code sample similar to my applications, but have not been able to find examples of anything that quite fits.

Any help would be appreciated!

  • 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-05T18:37:44+00:00Added an answer on June 5, 2026 at 6:37 pm

    You can only grab one thing at a time, all the URLs at once, display name, or the spaces. I would not use regular expressions per say to do this, but here is how I would go about it if I absolutely had to use regex:

    To grab the url in a line: \.\./.*\.html?

    To grab the display name: (?<=("|b)>)[a-ZA-Z].+?(?=(</(a|b)))

    To grab the spaces (simply): &nbsp;


    I would first split the file by the <br> tag to get the individual lines. And the run the regex above to pull out the url, display name, and spaces and combine them in a delimited output. I’m sure Java has a preg_match_all equivalent to match all patterns found (would be useful for the spaces & counting them)

    Note that these patterns were tested in Sublime Text and probably will not work in Java without a little tweaking. I can modify my answer later to include the Java if needed, but for a one-off thing like this you may be better off using Python or some other scripting language.

    Best of luck!

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

Sidebar

Related Questions

Possible Duplicate: RegEx match open tags except XHTML self-contained tags If I have a
Possible Duplicate: RegEx match open tags except XHTML self-contained tags I have this list
Possible Duplicate: RegEx match open tags except XHTML self-contained tags I have a HTML
Possible Duplicate: RegEx match open tags except XHTML self-contained tags i want to grap
Possible Duplicate: RegEx match open tags except XHTML self-contained tags What is the fastest
Possible Duplicate: RegEx match open tags except XHTML self-contained tags How to remove single
Possible Duplicate: RegEx match open tags except XHTML self-contained tags I am having trouble
Possible Duplicate: RegEx match open tags except XHTML self-contained tags Hello first of I
Possible Duplicate: RegEx match open tags except XHTML self-contained tags how can I replace
Possible Duplicate: Strip html from strings in python RegEx match open tags except XHTML

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.