Last active
September 27, 2016 17:51
-
-
Save advorak/f58f92e88a5f0193c59c06958b6e0397 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = ` | |
OUT: 1111 | |
OUT: andy | |
OUT: 121 OUT: 1324 | |
NOTOUT: 1114 | |
IN: 144`; | |
var values = []; | |
var pattern = //; /* Given the data above, suggest a regular expression to capture the lines containg "OUT: (a number)", also ignoring the lines NOTOUT and IN.. */ | |
values = data.match(pattern); | |
/* The returned array is: | |
values == ["OUT: 1111", "OUT: 121", "OUT: 1324"] | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = ` | |
OUT: 1111 | |
OUT: andy | |
OUT: 121 OUT: 1324 | |
NOTOUT: 1114 | |
IN: 144`; | |
var values = []; | |
var pattern = /(\n|\s)OUT:\s+\d{3,4}/g; /* Given the data above, suggest a regular expression to capture the lines containg "OUT: (a number)", also ignoring the lines NOTOUT and IN.. */ | |
values = data.match(pattern); | |
/* The returned array is: | |
values == [" OUT: 1111", " OUT: 121", " OUT: 1324"] | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment