var str = "文字列 string
ID | Name | Phone th> |
---|
01 | 張三1234567 | < td>02gt;李思 | gt;343434 |
gt;gt;03 | 王Wu | 685654 |
文字列文字列";
var regRecord = new RegExp('\
\([ 0-9]{ 2})\gt;\ | ([^\gt;\ |
([0-9] )\\','g'); var fieldIndex = { 'Id' : 1 , 'Name' : 2 , 'Phone' : 3 } var g_records = [],record; while ((record = regRecord.exec(str)) != null){ g_records.push({ 'Id' : RegExp[" $" fieldIndex.Id ] ,'Name' : RegExp["$" fieldIndex.Name] ,'Phone' : RegExp["$" fieldIndex.Phone] }); } // この時点で、g_records は一致するデータ テーブルを保存し、印刷して確認します。 for(var i=0;ialert("ID:" g_records[i].Id ";名前:" g_records[i].Name ";電話:" g_records[i].Phone);
|
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
著者別の最新記事
-
2025-02-26 03:58:14
-
2025-02-26 03:38:10
-
2025-02-26 03:17:10
-
2025-02-26 02:49:09
-
2025-02-26 01:08:13
-
2025-02-26 00:46:10
-
2025-02-25 23:42:08
-
2025-02-25 22:50:13
-
2025-02-25 21:54:11
-
2025-02-25 20:45:11