Saturday 15 September 2012

javascript - Filter out second set of digits with regex -


In my HTML markup, there will be several elements with the following naming scheme:
  name = "[]. Time Required []. Time"   

Between two sets of brackets, there should be numbers with at least one possibly two digits. I need to filter the second group of points.

Disclaimer: This is my first time that you want to know regex.

This is my pattern so far:

  var re = /> field {1,2} \] .timeEntries? [= {D} {1}}} \\\\. Time =;   
  1. I'm not sure that I should use the * or + character to indicate two possible digits.
  2. Is this the right place () to replace?
  3. I need to avoid this period. '<< Li>
  4. Whatever suggestions you can give, it is appreciated. For example, if I
      name = "[10] .timeEntries [9]. Time"   < P> I just want to put 9 in one variable Neither, use  {1,2}   
        \ [\ d {1,2} \]. Time indication \ [(\ d {1,2}) \] \. Time   

    This clearly indicates 1 or 2 points.

    In addition, yes, you should avoid . 's

    You can use it like this:

      var re = /> field {0}} {1,2}) ] \ time /. Var myNumber = "[0] .timeEntries [47] Time" .mail (again) [1];   

    will now be 47 in myNumber .

    One last word of the warning is included in myNumber string "47" If you intend to use it as a number, then you You must use parseInt or use + :

      var myNumber = + "[0] .timeEntries [47] Time ".match (again) [1];    

No comments:

Post a Comment