È uno schema davvero ottuso. Ero così sicuro che non avrebbe funzionato che non ci ho nemmeno provato. Allora, perché funziona?
L'obiettivo sembra essere quello di sostituire le sequenze virgoletta-virgola-virgoletta, ma solo all'interno delle [parentesi quadre]. In qualche modo, la prospettiva positiva riesce a farlo.
(?=[^\[\]]*\])
significa "cerca avanti zero o più caratteri che non siano parentesi quadre, seguiti da una parentesi quadra chiusa".
Quindi la virgoletta-virgoletta-virgoletta prima di [ non può corrispondere perché l'espressione regolare non riesce a individuare la ] finale senza essere interrotta da [.
E la virgoletta-virgoletta-virgoletta finale dopo ] non può corrispondere perché non c'è un altro ].
e la virgoletta-virgola-virgoletta nel mezzo... funziona.
Fantastico, immagino. Ma in realtà è un bel po' di lavoro per il motore delle espressioni regolari; l'aspetto positivo è la scansione continua fino alla fine della stringa. Non lascerei che un futuro manutentore lo capisca senza qualche commento, e probabilmente lo farei più così:
source = "\[
",":["11000278031.胡剑","11000259239.胡慧","11000426432.叶子","11000445039.张大为","11000469637.詹浏洋","11000480631.李书颖"],","
]\";
Write( source );
findthis = "\!",\!""; // ","
replacewith = "&";
// goal: replace findthis
// with replacethis
// but only inside the [ ... ] square brackets.
If( 0 < Contains( source, "[" ) < Contains( source, "]" ), "ok", Throw( "something wrong here" ));
parts = Words( source, "[]" );
If( N Items( parts ) == 3, "ok", Throw( "this needs more thought" ));
Substitute Into( parts[2], findthis, replacewith );
result = parts[1] || "[" || parts[2] || "]" || parts[3];
Write( result );
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookahead_assertion
Grazie Craige!
In realtà, voglio solo sapere come questo JSON può essere trasformato in una tabella perfetta
tx="\[[{"title":"AA,AA","BName":"AA","BCode":"605366","orgCode":"82004416","orgName":"AA","orgSName":"AA","publishDate":"2025-12-28 00:00:00.","infoCode":"AP202512281809952250","column":"002004006001","predictNextTwoYearB":"","predictNextTwoYearPe":"","predictNextYearB":"","predictNextYearPe":"","predictThisYearB":"","predictThisYearPe":"","predictLastYearB":"","predictLastYearPe":"","actualLastTwoYearB":"","actualLastYearB":"","industryCode":"","industryName":"","emIndustryCode":"","indvInduCode":"538","indvInduName":"AA","emBCode":"","emBValue":"","emBName":"","lastEmBCode":"","lastEmBValue":"","lastEmBName":"","BChange":"","reportType":2,"author":["11506051.AA"],"indvIsNew":"001","researcher":"AA","newListingDate":"2020-08-12 00:00:00.","newPurchaseDate":"2020-07-31 00:00:00.0","newIssueB":9.98,"newPeIssueA":22.78,"indvAimBT":"","indvAimBL":"","attachType":"0","attachSize":383,"attachPages":3,"encodeUrl":"6XT6d6nxZNcP9JXS1dtw9ivwowNnxWgBjsEKvrMIHoo=","sBName":"","sBCode":"","B":"SHANGHAI","authorID":["11506051"],"count":1,"orgType":"white"},{"title":"AAI,AA","BName":"AA","BCode":"688800","orgCode":"80036717","orgName":"AA","orgSName":"AA","publishDate":"2025-12-28 00:00:00.","infoCode":"AP202512281809913359","column":"002004001003","predictNextTwoYearB":"2.67","predictNextTwoYearPe":"32.97","predictNextYearB":"2.08","predictNextYearPe":"42.24","predictThisYearB":"1.46","predictThisYearPe":"60.44","predictLastYearB":"","predictLastYearPe":"","actualLastTwoYearB":"","actualLastYearB":"","industryCode":"","industryName":"","emIndustryCode":"","indvInduCode":"459","indvInduName":"AA","emBCode":"007","emBValue":"3","emBName":"AA","lastEmBCode":"007","lastEmBValue":"3","lastEmBName":"AA","BChange":3,"reportType":2,"author":["11392732.AA","11524834.AA"],"indvIsNew":"001","researcher":"AA,AA","newListingDate":"2021-07-22 00:00:00.","newPurchaseDate":"2021-07-12 00:00:00.0","newIssueB":15.02,"newPeIssueA":24.49,"indvAimBT":"","indvAimBL":"","attachType":"0","attachSize":764,"attachPages":5,"encodeUrl":"6XT6d6nxZNcP9JXS1dtw9snalC40a3QwRrj9tML8YAw=","sBName":"AA","sBCode":"0301","B":"SHANGHAI","authorID":["11392732","11524834"],"count":1,"orgType":"white"},{"title":"AA,AA","BName":"AA","BCode":"601038","orgCode":"80064","orgName":"AA","orgSName":"AA","publishDate":"2025-12-28 00:00:00.","infoCode":"AP202512281809893801","column":"002004002003","predictNextTwoYearB":"0.9","predictNextTwoYearPe":"15.7600","predictNextYearB":"0.8100","predictNextYearPe":"17.4900","predictThisYearB":"0.7900","predictThisYearPe":"17.9200","predictLastYearB":"","predictLastYearPe":"","actualLastTwoYearB":"","actualLastYearB":"","industryCode":"","industryName":"","emIndustryCode":"","indvInduCode":"910","indvInduName":"AA","emBCode":"007","emBValue":"3","emBName":"AA","lastEmBCode":"007","lastEmBValue":"3","lastEmBName":"AA","BChange":3,"reportType":2,"author":["11379333.AA"],"indvIsNew":"001","researcher":"AA","newListingDate":"2012-08-08 00:00:00.","newPurchaseDate":"2012-07-27 00:00:00.0","newIssueB":5.4,"newPeIssueA":14.44,"indvAimBT":"","indvAimBL":"","attachType":"0","attachSize":321,"attachPages":4,"encodeUrl":"6XT6d6nxZNcP9JXS1dtw9vuL66I7rHatL9vNIud7cP0=","sBName":"AA","sBCode":"0101","B":"SHANGHAI","authorID":["11379333"],"count":1,"orgType":"white"},{"title":"AA:AA,AA","BName":"AA","BCode":"002488","orgCode":"80162","orgName":"AA","orgSName":"AA","publishDate":"2025-12-25 00:00:00.","infoCode":"AP202512251807934364","column":"002004001003","predictNextTwoYearB":"1.0100","predictNextTwoYearPe":"8.4","predictNextYearB":"0.3300","predictNextYearPe":"25.4","predictThisYearB":"0.0600","predictThisYearPe":"131.8","predictLastYearB":"","predictLastYearPe":"","actualLastTwoYearB":"","actualLastYearB":"","industryCode":"","industryName":"","emIndustryCode":"","indvInduCode":"481","indvInduName":"AA","emBCode":"007","emBValue":"3","emBName":"AA","lastEmBCode":"","lastEmBValue":"","lastEmBName":"","BChange":2,"reportType":2,"author":["11250834.AA","11245529.AA","11442637.AA"],"indvIsNew":"001","researcher":"AA,AA,AA","newListingDate":"2010-10-21 00:00:00.","newPurchaseDate":"2010-10-11 00:00:00.0","newIssueB":22,"newPeIssueA":73.33,"indvAimBT":"","indvAimBL":"","attachType":"0","attachSize":2285,"attachPages":19,"encodeUrl":"MKF7cC+MZ9vDOQWsqD7ZgmRE9eUeYHJK9njuGLTcICI=","sBName":"AA(1)","sBCode":"0201","B":"SHENZHEN","authorID":["11250834","11245529","11442637"],"count":1,"orgType":"white"},{"title":"BDAA,AA","BName":"AA","BCode":"688621","orgCode":"80064","orgName":"AA","orgSName":"AA","publishDate":"2025-12-25 00:00:00.","infoCode":"AP202512251807725254","column":"002004006003","predictNextTwoYearB":"2.4600","predictNextTwoYearPe":"28.0","predictNextYearB":"2.2600","predictNextYearPe":"30.5400","predictThisYearB":"1.8","predictThisYearPe":"38.3300","predictLastYearB":"","predictLastYearPe":"","actualLastTwoYearB":"","actualLastYearB":"","industryCode":"","industryName":"","emIndustryCode":"","indvInduCode":"727","indvInduName":"AA","emBCode":"007","emBValue":"3","emBName":"AA","lastEmBCode":"007","lastEmBValue":"3","lastEmBName":"AA","BChange":3,"reportType":2,"author":["11296231.AA","11486715.AA"],"indvIsNew":"001","researcher":"AA,AA","newListingDate":"2021-06-21 00:00:00.","newPurchaseDate":"2021-06-09 00:00:00.0","newIssueB":26.89,"newPeIssueA":29.72,"indvAimBT":"","indvAimBL":"","attachType":"0","attachSize":315,"attachPages":4,"encodeUrl":"MKF7cC+MZ9vDOQWsqD7ZgvFJHAi4XRobbkVOxAB2GK4=","sBName":"AA","sBCode":"0101","B":"SHANGHAI","authorID":["11296231","11486715"],"count":1,"orgType":"white"}]]\";
d1 =jsontodatatable(tx);
Ciò aumenterà il numero di linee