File tree Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -689,6 +689,29 @@ var repeatedSubstringPattern = function (s) {
689
689
};
690
690
```
691
691
692
+ > 正则匹配
693
+ ``` javascript
694
+ /**
695
+ * @param {string} s
696
+ * @return {boolean}
697
+ */
698
+ var repeatedSubstringPattern = function (s ) {
699
+ let reg = / ^ (\w + )\1 + $ /
700
+ return reg .test (s)
701
+ };
702
+ ```
703
+ > 移动匹配
704
+ ``` javascript
705
+ /**
706
+ * @param {string} s
707
+ * @return {boolean}
708
+ */
709
+ var repeatedSubstringPattern = function (s ) {
710
+ let ss = s + s;
711
+ return ss .substring (1 , ss .length - 1 ).includes (s);
712
+ };
713
+ ```
714
+
692
715
### TypeScript:
693
716
694
717
> 前缀表统一减一
@@ -894,8 +917,10 @@ impl Solution {
894
917
}
895
918
```
896
919
### C#
920
+
921
+ > 前缀表不减一
922
+
897
923
``` csharp
898
- // 前缀表不减一
899
924
public bool RepeatedSubstringPattern (string s )
900
925
{
901
926
if (s .Length == 0 )
@@ -920,6 +945,13 @@ public int[] GetNext(string s)
920
945
}
921
946
```
922
947
948
+ > 移动匹配
949
+ ``` csharp
950
+ public bool RepeatedSubstringPattern (string s ) {
951
+ string ss = (s + s ).Substring (1 , (s + s ).Length - 2 );
952
+ return ss .Contains (s );
953
+ }
954
+ ```
923
955
### C
924
956
925
957
``` c
You can’t perform that action at this time.
0 commit comments