How to process this string via regular expression

Posted by iiduce on Stack Overflow See other posts from Stack Overflow or by iiduce
Published on 2010-04-07T10:09:18Z Indexed on 2010/04/07 10:13 UTC
Read the original article Hit count: 233

Filed under:
|

my string style like this:

expression1/field1+expression2*expression3+expression4/field2*expression5*expression6/field3

a real style mybe like this:

computer/(100)+web*mail+explorer/(200)*bbs*solution/(300)

"+" and "*" represent operator "computer","web"...represent expression (100),(200) represent field num . field num may not exist.

I want process the string to this:

/(100)+web*+explorer/(200)bbs/(300)

rules like this:

if expression length is more than 3 and its field is not (200), then add brackets to it.

© Stack Overflow or respective owner

Related posts about string-manipulation

Related posts about regex