• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15const str = `
16a1  B!����123  \n\t Hello&
17abc  D������  456\f\n XYZ#
18xy9   Z  .�� 789\rA1b2#
19mno123   R ����  01\f\twd24C3%
20abcde  K, ��❤️��  345  \n\t142 Codex!
21z7  ���� ;;;  89\rA23Cs@1
22abcd   M  :  ��\n\tq4!
231pqr     J  !  ����  6789 \t\t11x12&
24xyz12   B  *  ��  3\f!ww A3bC%
25`;
26const regex = new RegExp(`(?<=(?<![\\w])(?:[\\uD83C-\\uDBFF\\uDC00-\\uDFFF]{1,2})(?![\\w\\d]))\\s+|
27    \\s+(?=(?<=[a-zA-Z0-9]{1,})(?:[\\f\\r\\n\\t\\v]+)(?=\\w{3,}\\w+))`, 'gimu');
28const matches = str.match(regex);
29print(JSON.stringify(matches));
30