Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- boy, man,girl, woman,tyrannosaurus rex, lion
- hat, cat, rat, c3po, @gmail
- /^w(s*,?s*w)*$/
- /^s*w(s*,?s*w)*s*$/
- /^s*[a-z0-9](s*,?s*[a-z0-9])*s*$/
- /^s*([a-z0-9]+(s[a-z0-9]+)*)(s*,s*([a-z0-9]+(s[a-z0-9]+)*))*s*$/
- var re = /^(w+,? ?)+$/;
- var str1 = "boy, man,girl, woman,tyrannosaurus rex, lion";
- var str2 = "hat, cat, rat, c3po, @gmail";
- alert(str1.test(re)); // true
- alert(str2.test(re)); // false
- /^(w+s?[ws]*)(,s*w+s?[ws]*)*$/
- Assert position at the beginning of a line (at beginning of the string or after a line break character) «^»
- Match the regular expression below and capture its match into backreference number 1 «(w+s?[ws]*)»
- Match a single character that is a “word character” (letters, digits, and underscores) «w+»
- Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
- Match a single character that is a “whitespace character” (spaces, tabs, and line breaks) «s?»
- Between zero and one times, as many times as possible, giving back as needed (greedy) «?»
- Match a single character present in the list below «[ws]*»
- Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
- A word character (letters, digits, and underscores) «w»
- A whitespace character (spaces, tabs, and line breaks) «s»
- Match the regular expression below and capture its match into backreference number 2 «(,s*w+s?[ws]*)*»
- Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
- Note: You repeated the capturing group itself.
- The group will capture only the last iteration.
- Put a capturing group around the repeated group to capture all iterations. «*»
- Match the character “,” literally «,»
- Match a single character that is a “whitespace character” (spaces, tabs, and line breaks) «s*»
- Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
- Match a single character that is a “word character” (letters, digits, and underscores) «w+»
- Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
- Match a single character that is a “whitespace character” (spaces, tabs, and line breaks) «s?»
- Between zero and one times, as many times as possible, giving back as needed (greedy) «?»
- Match a single character present in the list below «[ws]*»
- Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
- A word character (letters, digits, and underscores) «w»
- A whitespace character (spaces, tabs, and line breaks) «s»
- Assert position at the end of a line (at the end of the string or before a line break character) «$»
- Created with RegexBuddy
- /^s*[a-z0-9]+(s+[a-z0-9]+)?(s*,s*[a-z0-9]+(s+[a-z0-9]+)?)*s*$/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement