我試圖將textarea
中的值更改爲僅包含十六進制數字。
舉例來說,如果我有這樣的textarea
:JavaScript - 從字符串中刪除所有內容但是十六進制
RMCP01
Mario Kart Wii
CCP items
* C27EF0EC 00000002
* 3FE08000 93BF1500
* 3BE00000 00000000
* 28345842 ff7f0080
* 8000000F 00000000
* 8000000E 00000001
* E0000000 00000000
* 28345842 fffb0004
* 8000000F 00000020
* 8000000E 00000001
* E0000000 00000000
* 28345842 fffd0002
* 8000000F 0000000B
* 8000000E 00000001
* E0000000 00000000
* 28345842 7fff8000
* 8000000F 00000009
* 8000000E 00000001
* E0000000 00000000
* 28345842 bfff4000
* 8000000F 00000004
* 8000000E 00000001
* E0000000 00000000
* 28345842 efff1000
* 8000000F 0000000E
* 8000000E 00000001
* E0000000 00000000
* 28345842 fbff0400
* 8000000F 0000000F
* 8000000E 00000001
* E0000000 00000000
* 28345842 fff70008
* 8000000F 00000007
* 8000000E 00000001
* E0000000 00000000
* 28345842 ffdf0020
* 8000000F 00000003
* 8000000E 00000001
* E0000000 00000000
* E2000001 00000000
* 48000000 809C1900
* DE000000 80008180
* 58010000 00000008
* DE000000 80008180
* 48100000 80001500
* DE000000 80008180
* 9421000F 0000008c
* 14000090 00000001
* E0000000 80008000
Connect Hacker
* 046592D8 3BA0270F
VR
* 28345842 ff7b0084
* 48000000 809BD748
* DE000000 90009380
* 5A010000 00009050
* 12000000 00008ae3
* E0000000 00000000
* 28345842 ddff2200
* 48000000 809BD748
* DE000000 90009380
* 5A010000 00009050
* 12000000 00000001
* E0000000 00000000
* 28345842 ff870078
* 48000000 809BD748
* DE000000 90009380
* 5A010000 00009050
* 12000000 00001388
* CC000000 00000000
* E0000000 80008000
RBC
* 045334B0 38000002
* 04533510 2C000003
Drift
* 048B5CC0 00000000
* 048B5CC4 00000000
* 048B5CC8 00010000
* 048B5B38 00010000
Invicibilty
* F6000001 80008100
* A88301A8 3BC00000
* 1400002C 60000000
* F6000001 80008100
* EC4300B2 C0630088
* D2000020 00000002
* 38000001 9803000A
* 80030008 00000000
* E0000000 80008000
BBB
283457E2 BFFE4001
048B59F8 43960000
E0000000 00000000
283457E2 BFFD4002
048B59F8 442F0000
E0000000 00000000
283457E2 FBEF0410
048B59F8 43110000
E0000000 00000000
283457E2 EBFF1400
048B59F8 40000000
E0000000 00000000
Deactivator
* 28348200 FEFF0100
* 8000000D 00000001
* 48000000 809C1900
* DE000000 80008180
* 58010000 00000008
* DE000000 80008180
* 4A100000 0000008C
* 30000000 00000014
* 14000000 00000014
* 14000004 00000000
* E0000000 00000000
* 28348200 FDFF0200
* 8000000D 00000000
* E0000000 80008000
結果是一切,但第一個字符。 (第一行更改爲「MCP01」)這是我的代碼:
function check() {
var c=$("#c").value;
c=c.replace(/[^A-Fa-f0-9]/, "");
return c;
}
出了什麼問題?
它應該是'$(「#C」)VAL()',而這種邏輯是行不通的,因爲'Deactivator'有一堆的有效十六進制字符它 – Esailija