File tree Expand file tree Collapse file tree 1 file changed +60
-2
lines changed Expand file tree Collapse file tree 1 file changed +60
-2
lines changed Original file line number Diff line number Diff line change
1
+ ## Convert to [ Regular Expression Matching] ( ../regular-expression-matching )
1
2
2
- ## TODO
3
- * write down thinking
3
+ * ` ? ` -> ` . `
4
+ * ` * ` -> ` .* `
4
5
6
+ This should work, yet, it exceeds the time limited.
7
+
8
+ ## Checkpoint / Timemachine
9
+
10
+ On modern OS, you can go back to some time you saved if your OS meets some problem.
11
+ such technology also can be used to solve this problem.
12
+
13
+ ```
14
+ S
15
+
16
+ [ a a b ]
17
+
18
+ [ a * b * ]
19
+
20
+ P
21
+
22
+
23
+ P is *, save current state.
24
+ ```
25
+
26
+ ` P ` goes on to next
27
+
28
+ ```
29
+
30
+ This state means * matches nothing
31
+
32
+ S
33
+
34
+ [ a a b ]
35
+
36
+ [ a * b * ]
37
+
38
+ P
39
+
40
+ ```
41
+
42
+ a mismatch found, ` P != S ` , so rollback to checkpoint.
43
+
44
+ ```
45
+ This state means * matches a
46
+
47
+ S
48
+
49
+ [ a a b ]
50
+
51
+ [ a * b * ]
52
+
53
+ P
54
+ ```
55
+
56
+ Each ` * ` will save to a checkpoint, and retry from nothing until a match is found.
57
+
58
+
59
+ ### Remaining tail
60
+
61
+ Sometimes, ` S ` meets the end, but the ` P ` not.
62
+ In this case, just to check remaining chars in ` P ` are all ` * ` .
You can’t perform that action at this time.
0 commit comments