regex - Regular expression to parse xaml binding-esque syntax -
As usual, regular expression is hurting my head.
I have the following string examples):
Customer: {path = customer name}, balance: {path = balance, string format = '{ 0: 0.00} '} Customer: {path = ClientName}, balance: {path = balance, string format =' your balance {0: 0.00}. '} I have a regular expression (Or any other method) which can divide it according to the wires and then the individual key / value value of each (The idea is to solve each one in XAM binding).
string1: {path = clientname} path = clientname string 2: {path = balance, string format = ' {0: 0.00} '} path = balance string format = {0: 0.00} At this time I have the following regular expression for splitting strings, but it is confused due to the value of StringFormat Gets value in '}'
(? +?)? {(. +?)} (? '') Any ideas how can I get it?
Thank you!
This is really tedious to solve this problem, but you can go here :
Technically, you are doing it wrong, you should use a parser, regular expressions are not made to deal with the nested match consensus, blah blah blah. We can hack it together, however, why not?
/ (? & Lt;! ') {([^'}] | '[^'] + ') +} (?!') / Its meat - {([^ '}] + |' [^ '] +'}} - Looks for two things: a) Whatever } < / Code> or ' is not a character ( [^'}] , and b) whatever appears string ( '[^'] + '< / Code>). It assumes that the string is a quote, a bunch of non-quoted text, and another quote. Looking at your examples, it should work.
This does not match '', it is a string in which this quote is' , because it is not saved, it is not easy to add it designed for quotation marks Is involved in implementing the principles that we have implemented now, so I can know if you can. You look great with regular expressions, and you have made at least one beginning before asking it, so I think you can understand how this is done in a string with \ ' Matches / P>
Edit: You're using ' s instead of " s. Sorry about that.
Comments
Post a Comment