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) {
689689};
690690```
691691
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+
692715### TypeScript:
693716
694717> 前缀表统一减一
@@ -894,8 +917,10 @@ impl Solution {
894917}
895918```
896919### C#
920+
921+ > 前缀表不减一
922+
897923``` csharp
898- // 前缀表不减一
899924public bool RepeatedSubstringPattern (string s )
900925{
901926 if (s .Length == 0 )
@@ -920,6 +945,13 @@ public int[] GetNext(string s)
920945}
921946```
922947
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+ ```
923955### C
924956
925957``` c
You can’t perform that action at this time.
0 commit comments