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 @@ -648,6 +648,29 @@ var repeatedSubstringPattern = function (s) {
648
648
};
649
649
```
650
650
651
+ > 正则匹配
652
+ ``` javascript
653
+ /**
654
+ * @param {string} s
655
+ * @return {boolean}
656
+ */
657
+ var repeatedSubstringPattern = function (s ) {
658
+ let reg = / ^ (\w + )\1 + $ /
659
+ return reg .test (s)
660
+ };
661
+ ```
662
+ > 移动匹配
663
+ ``` javascript
664
+ /**
665
+ * @param {string} s
666
+ * @return {boolean}
667
+ */
668
+ var repeatedSubstringPattern = function (s ) {
669
+ let ss = s + s;
670
+ return ss .substring (1 , ss .length - 1 ).includes (s);
671
+ };
672
+ ```
673
+
651
674
### TypeScript:
652
675
653
676
> 前缀表统一减一
@@ -853,8 +876,10 @@ impl Solution {
853
876
}
854
877
```
855
878
### C#
879
+
880
+ > 前缀表不减一
881
+
856
882
``` csharp
857
- // 前缀表不减一
858
883
public bool RepeatedSubstringPattern (string s )
859
884
{
860
885
if (s .Length == 0 )
@@ -879,6 +904,13 @@ public int[] GetNext(string s)
879
904
}
880
905
```
881
906
907
+ > 移动匹配
908
+ ``` csharp
909
+ public bool RepeatedSubstringPattern (string s ) {
910
+ string ss = (s + s ).Substring (1 , (s + s ).Length - 2 );
911
+ return ss .Contains (s );
912
+ }
913
+ ```
882
914
883
915
<p align =" center " >
884
916
<a href =" https://programmercarl.com/other/kstar.html " target =" _blank " >
You can’t perform that action at this time.
0 commit comments