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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:57:11+00:00 2026-05-15T08:57:11+00:00

Looking to find the appropriate regular expression for the following conditions: I need to

  • 0

Looking to find the appropriate regular expression for the following conditions:

I need to clean certain tags within free flowing text. For example, within the text I have two important tags: <2004:04:12> and <name of person>. Unfortunately some of tags have missing “<” or “>” delimiter.

For example, some are as follows:

1) <2004:04:12 , I need this to be <2004:04:12>
2) 2004:04:12>, I need this to be <2004:04:12>
3) <John Doe , I need this to be <John Doe>

I attempted to use the following for situation 1:

String regex = "<\\d{4}-\\d{2}-\\d{2}\\w*{2}[^>]";
String output = content.replaceAll(regex,"$0>");

This did find all instances of “<2004:04:12” and the result was “<2004:04:12 >”.
However, I need to eliminate the space prior to the ending tag.

Not sure this is the best way. Any suggestions.

Thanks

  • 1 1 Answer
  • 1 View
  • 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-15T08:57:11+00:00Added an answer on May 15, 2026 at 8:57 am

    Basically, you are looking for a negative look-ahead, like this:

    String regex = "<\\d{4}-\\d{2}-\\d{2}(?!>)";
    String output = content.replaceAll(regex,"$0>");
    

    This will help with the numeric “tags”, but since no regex can be intelligent enough to match an arbitrary name, you either must define very closely what a name can look like, or deal with the fact that the same approach is impossible for “name” tags.

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

Sidebar

Related Questions

I'm looking to find the Javascript Event I need to put into jQuery's .bind
I'm looking for the appropriate way of storing files into the document folder within
Basically I am looking for a regular expression for phone numbers. Inputs can be:
I'm looking to find information on how to update my XCode program that has
I am looking to find the slope between two vectors via linear regression in
I'm looking to find the add-on which will draw a tooltip window at the
I am looking to find a way to programatically (C++) control/secure access to the
I'm looking to find something along the lines of Checkstyle for Visual Studio. I've
I'm looking to find a galleria replacement, hopefully using jQuery but other javascript frameworks
I am looking to find out if a web page has changed, I was

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.