Parsing complex string using regex
- by wojtek_z
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.