javascript - Help with regexp to extract values from inside brackets -
I would like to get a regexp that will remove the following. I have a regexp to validate it (I've mixed it together, so it can not be the best or most efficient).
some.text_here: [12,34], [5678]
The first part of the colon may include a period or underlining The bracketed numbers after the colon are directing [x1, y1], [x2, y2] ... I just need a number from here.
And here is the regexp validator I was using (for javascript): <\ [\ D +, \ d +], \ [\ d +, \ d +]) / Pre>
I'm quite new to regexp, but I can not know how to extract values so that I get
name = "some.text_here" x1 = 12 y1 Can do = 34 x2 = 56 y2 = 78
thanks for any help!
Try this regular expression:
/ ^ ([ \ W \ d -_.] *): \ [(\ D +), (\ d +)], \ [(\ D +), (\ d +)] / var str = "some.text_here: [ 12,34], [56,78] "; Var match = str.match (/ ^ ([\ w \ d -_.] *): \ [(\ D +), (\ d +)], \ [(\ d +), (\ d +) ] /); Warning ("name =" + [[1] + "\" "\ n" + "x1 =" + match [2] + "\ n" + "x2 =" + match [3] + "\ n" + "Y1 =" + match [4] + "\ n" + "y2 =" + match [5]);
Comments
Post a Comment