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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:20:55+00:00 2026-05-15T07:20:55+00:00

My regex skills are not very good and recently a new data element has

  • 0

My regex skills are not very good and recently a new data element has thrown my parser into a loop

Take the following string

“+USER=Bob Smith-GROUP=Admin+FUNCTION=Read/FUNCTION=Write”

Previously I had the following for my regex : [+\\-/]

Which would turn the result into

USER=Bob Smith
GROUP=Admin
FUNCTION=Read
FUNCTION=Write
FUNCTION=Read

But now I have values with dashes in them which is causing bad output

New string looks like “+USER=Bob Smith-GROUP=Admin+FUNCTION=Read/FUNCTION=Write/FUNCTION=Read-Write”

Which gives me the following result , and breaks the key = value structure.

USER=Bob Smith
GROUP=Admin
FUNCTION=Read
FUNCTION=Write
FUNCTION=Read
Write

Can someone help me formulate a valid regex for handling this or point me to some key / value examples. Basically I need to be able to handle + – / signs in order to get combinations.

  • 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-15T07:20:56+00:00Added an answer on May 15, 2026 at 7:20 am

    You didn’t specify what regex engine you’re using, but this works if you’ve got lookahead/lookbehind.

    It works on the premise that the keys are all uppercase only, whilst the values aren’t – not sure if that’s a valid assumption, but if it’s not then as noted things will get complicated and messy.

    (?<=[+-\/])[A-Z]+=(?:(?![A-Z]+=)[^=])+(?=[+-\/]|$)
    

    And here’s my attempt to explain that (not sure how much this makes sense):

    (?x)         # enable regex comment mode
    (?<=[+-\/])  # start with one of the delimiters, but excluded from match
    [A-Z]+       # match one or more uppercase (for the key)
    =            # match the equal sign
    
    (?:          # start non-capturing group
    
      (?!          # start negative lookahead, to prevent keys matching
        [A-Z]+=      # a key and equals (since in negative lookahead, this is what we exclude)
      )            # end the negative lookahead
      [^=]         # match a character that's not =
    
    )+           # end non-capturing group, match one or more times, until...
    
    (?=[+-\/]|$) # next char must be delimiter or end of line for match to succeed
    

    For Java string->regex, backslashes need escaping (as would quotes, if there were any):

    Pattern p = Pattern.compile("(?<=[+-\\/])[A-Z]+=(?:(?![A-Z]+=)[^=])+(?=[+-\\/]|$)");
    

    And if capturing groups are needed, just add parens round the appropriate parts:

    Pattern p = Pattern.compile("(?<=[+-\\/])([A-Z]+)=((?:(?![A-Z]+=)[^=])+(?=[+-\\/]|$))");
    

    The matching part of this, to turn it into newline delimited text, is something like…

    Matcher m = p.Matcher( InputText );
    StringBuffer Result = new StringBuffer("");
    
    while ( m.find() )
    {
       Result.append( m.Group() + "\n" );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Regex Expression for finding a string which has one @ and should not start
I've been wanting to improve my regex skills for quite some time now and
RegEx has always confused me. I have a string like this: IDE\DiskDJ205GA20_____________________________A3VS____\5&1003ca0&0&0.0.0 Or Sometimes
I am looking to improve my regex skills for use in my Ruby programming.
Regex.Match has a .Success and .NextMatch why doesnt it have a GetEnumerator function? With
Regex fun again... Take for example http://something.com/en/page I want to test for an exact
regex not working as wanted Code example: widgetCSS = #widgetpuffimg{width:100%;position:relative;display:block;background:url(/images/small-banner/Dog-Activity-BXP135285s.jpg) no-repeat 50% 0; height:220px;}
My regex skills are a bit rusty. Can someone provide a expression that I
The sad truth about this post is that I have poor regex skills. I
RegEx = new RegExp(sourcevalue, gi); temp[i] = Selectors[i].cssText.replace(RegEx, targetvalue); where sourcevalue = rgb(255,0,0) and

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.