Home > front end >  If the extract content between two $sign
If the extract content between two $sign

Time:09-30

Text is as follows, extract content between two $, but \ $not, how to write

$ aa $BBBB $ aa $bb $ aa $DDD $ aa \ $aaa $

Every two $is a set, extract content between this group.
Consult, thank you for your warrior, try a few times without success.

CodePudding user response:

STR. The split () tried
Reference: https://www.w3school.com.cn/js/jsref_split.asp

CodePudding user response:

 
Var STR="$$$aa BBBB $bb $aa aa aa \ \ $DDD $$$" aaa.
Var arr=[];
STR. Replace (/\ $(. *? \ [^ \ \ \ $]) $/g, the function (s, a) {
Arr. Push (a);
});
Alert (arr);
  • Related