If I need to do regex replacement 27000 times with different pattern search and replacement, how to shorten it?
The re.sub need to be done about 27000 times with different first and second argument
I wrote it 27000 times (27000 lines) in python
How to shorten it?
Code:
import re
from _Arm64HexDatabase import *
handle_file1 = open("example1", "rb")
hex_read = handle_file1.read()
handle_file1.close()
hfile3 = open("result1.txt", "a")
hex_read = re.sub(hex_suba64w0w0w0, hex_mova64w0c0, hex_read)
...
hex_read = re.sub(hex_suba64w31w31w31, hex_mova64w31c0, hex_read)
hex_read = re.sub(hex_suba64x0x0x0, hex_mova64x0c0, hex_read)
...
hex_read = re.sub(hex_suba64x31x31x31, hex_mova64x31c0, hex_read)
hex_read = re.sub(hex_suba64w0w0c0, hex_mova64w0w0, hex_read)
...
hex_read = re.sub(hex_suba64w31w31c0, hex_mova64w31w31, hex_read)
hex_read = re.sub(hex_suba64x0x0c0, hex_mova64x0x0, hex_read)
...
hex_read = re.sub(hex_suba64x31x31c0, hex_mova64x31x31, hex_read)
hex_read = re.sub(hex_suba64w0w0wzr, hex_mova64w0w0, hex_read)
...
hex_read = re.sub(hex_suba64w31w31wzr, hex_mova64w31w31, hex_read)
hex_read = re.sub(hex_suba64x0x0xzr, hex_mova64x0x0, hex_read)
...
hex_read = re.sub(hex_suba64x31x31xzr, hex_mova64x31x31, hex_read)
hex_read = re.sub(hex_adda64w0w0c0, hex_mova64w0w0, hex_read)
...
hex_read = re.sub(hex_adda64w31w31c0, hex_mova64w31w31, hex_read)
hex_read = re.sub(hex_adda64x0x0c0, hex_mova64x0x0, hex_read)
...
hex_read = re.sub(hex_adda64x31x31c0, hex_mova64x31x31, hex_read)
hex_read = re.sub(hex_adda64w0w0wzr, hex_mova64w0w0, hex_read)
...
hex_read = re.sub(hex_adda64w31w31wzr, hex_mova64w31w31, hex_read)
hex_read = re.sub(hex_adda64x0x0xzr, hex_mova64x0x0, hex_read)
...
hex_read = re.sub(hex_adda64x31x31xzr, hex_mova64x31x31, hex_read)
The re.sub need to be done about 27000 times with different first and second argument
I wrote it 27000 times (27000 lines) in python
How to shorten it?