简体   繁体   中英

Please help me to find Regex to split my string

1. Need regex to find a string is whether enclosed by a brace , that may contains brace with in enclosed string.If Yes Then needs to stripe the 1nd and last braces. eg: {StatusData/ResponseCode,RespMessage,{ArrivalMethods/AvailableArrivalMethod/AvailableArrivalMethodName,AvailableFFMCenter}}

INTO StatusData/ResponseCode,RespMessage,{ArrivalMethods/AvailableArrivalMethod/AvailableArrivalMethodName,AvailableFFMCenter}

2. I need a regex to find a string is whether comma separated of brace sets or not and if comma separated then it needs to split as follows wwith comma. eg: {StatusData/ResponseCode,RespMessage,{ArrivalMethods/AvailableArrivalMethod/AvailableArrivalMethodName,AvailableFFMCenter}} ,{ServiceHeaders/clientSessionKey}, {Shoppingcart/OrderId,CatalogId}

INTO

1. {StatusData/ResponseCode,RespMessage,{ArrivalMethods/AvailableArrivalMethod/AvailableArrivalMethodName,AvailableFFMCenter}} 2. {ServiceHeaders/clientSessionKey} 3. {Shoppingcart/OrderId,CatalogId}

Regarding problem 1: that cannot be solved with a regex unless you limit the depth of the nesting. Read this post for an example of how to do it with a limit of 3 (and a description of how to do it for other limits). As that example makes clear, this is a monster to do with regex; you're better off doing this in code if that's an option for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM