Skip to content

Commit ecd2928

Browse files
committed
#100DaysOfCode - Day 7
1 parent d9d1ce9 commit ecd2928

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

06 - Type Ahead/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,23 @@ You can chain thens together to transform values or run additional async actions
4646
// Fail
4747
});
4848
```
49+
50+
Now we have all the data we need by sending a request to the server. Next we need to detect user input in search bar.
51+
We need to add two event listener to detect text change.
52+
```JavaScript
53+
textField.addEventListener('change', didChangeText);
54+
textField.addEventListener('keyup', didChangeText);
55+
```
56+
57+
### Regular Expression
58+
59+
When user types anything in the search bar, we need to update the list accordingly. Regular expressions are patterns used to match character combinations in strings. The search patter can be used for text search and text replace operation. When you search for data in a text, you can use this search pattern to describe what you are searching for.
60+
61+
```JavaScript
62+
var re = /ab + c/;
63+
var re = new RegExp("ab + c");
64+
65+
var str = "Visit W3School";
66+
var re = new RegExp("w3school", "i");
67+
var result = str.search(re);
68+
```

0 commit comments

Comments
 (0)