javascript - New to Regular Expressions need help -
I need a form with a button and window for input
which is an array of Regular expression will check
and the letters + numbers will be correctly matched. Example wxyz [some place BTW] 0960000
or mix of numbers and letters [some place beeted] + no 01xg [some place beet] 0960000
The array has four objects for now
Once found, I need a function, when a match is found, a new page or window will open.
Thank you for your help.
To reply to the Michael
P>
var matches = []; Var re = / whatever /; Foo.forEach (function (L) {if (re.exec (el)) matches.push (el);}); To try to answer the part of the regular expression: I do not know what "exact match" is for you, and I'm assuming that "some place "Only in the middle, in other words, and I am accepting letters which means that the English alphabet should be matched from 'A' to 'J' in less and upper case and digits 0-9 (Otherwise, other language words be matched) Can be).
The first pattern / [a-zA-Z0- 9] + \ s * 0960000 / would replace "\ S *" in "\ s +" if at least, instead of zero or more space characters One is by changing the "\ S" to match the tab character (and some low-used space characters) is not desirable.
For the second pattern, I do not know what "number 01xg" means, but if it means that the number after that string will be, then the pattern / [a-zA-Z0- 9] + \ S * [0- 9] + \ s * 01xg \ s * 0960000 /. The same behavior applies in the form of the above.
In addition to this, it will match the partial string. If the string matches perfectly (if there is nothing in the string, which should be present in addition to the one that matches), "^" at the beginning of the pattern to anchor the beginning of the string and finally "$ "For an anchor at the end of the Add String, for example, / [a-zA-Z0- 9] + \ s * 0960000 / match" foo_bar 5 0960000 ", but / ^ [a-zA-Z0- 9] + \ S * 0960000 $ / no
To learn more about regular expressions in Javascript, take a look (the link takes you to the JS version 1.5 context, which should apply to all JS enabled browsers).
(: To match any position, because they are overlapping parts, then you can use the following pattern: / [a-zA-Z0- 9 ] + (?: \ S * [0-9] + \ s * 01xg)? \ S * 0,960,000 /. Question mark matches the part that is different - a non-matching group (? Foo) In - once or zero times (: Foo)? And (?: Foo |) in this case do the same thing, but I'm not sure whether there is a performance difference or not; I recommend using it Which you More understandable, so you can read it later.
Comments
Post a Comment