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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:30:20+00:00 2026-05-26T09:30:20+00:00

I have a field in my table that holds a string denoting some object

  • 0

I have a field in my table that holds a string denoting some object levels, like so:

"<3<"
"<3<5<"
"<3<5<49<"

etc.

I have a function that is to remove a level from such a string, without knowing the position of the level in the string itself. Concretely, I would like to remove “3”. The result should be:

"0"
"<5<"
"<5<49<"

If I would, however, want to remove 5, and not 3, the result should be this:

"<3<"
"<3<"
"<3<49<"

Lastly, if I chose to remove 49 instead of 3 or 5, I would like to get this:

"<3<"
"<3<5<"
"<3<5<"

As you can see, the position of the substring that is to be removed varies – sometimes it’s the leftmost one, sometimes in the middle, sometimes the rightmost one. What is important after all this is:

  1. If the number I am removing is the only value, enclosed in “less than” signs (as in “<3<” while removing 3), the new result must be 0.
  2. If the number I am removing is not the only value, the only thing that matters is that the final notation stays the same – as in, the entire string must remain enclosed in “less than” symbols, and substrings of multiple “less than” symbols in a row must not happen (as in, “3<<5<” is not allowed).

Is there an easy regex way to handle this with php and mysql, or should I just make 3 manual checks?

P.S. While I may have posed it as such, this is not homework but an actual work issue.

  • 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-26T09:30:21+00:00Added an answer on May 26, 2026 at 9:30 am

    for each line two replacements: (for example, you want to remove “3”)

    replace "^<3<$" -> "0"; 
    replace "<3" -> "";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with a name (varchar) field that only holds numeric string
I have a field in an Azure table that holds date times in string
I have a table it includes 3 foreign key field like that: My Table:
I have a database table that holds parent and child records much like a
In SQL Server 2005 I have an id field in a table that has
I have table that contain date and time field. id|date|time ========= 1|01/01/2001|10:45 2|01/02/2002|11:45 3|01/03/2003|12:45
I have a table that records a sequence of actions with a field that
I have a table that has an AUTO_INCREMENT field. Currently, it is also a
I have a table that contains members names and a field with multiple ID
I have an SQL Server 2005 table that has a varchar(250) field which contains

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.