我正在重新装修Woocommerce商店,我需要设置重定向,以将包括类别名称的旧URL发送到不会的新URL。
编辑:新旧URL 都包含On Error Resume Next
'SETS 'LOAD DRIVER' PRIVILEGE.
Set objWMIService = GetObject("Winmgmts:")
objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege", True
'SETS PRINTER PORT.
Set objNewPort = objWMIService.Get _
("Win32_TCPIPPrinterPort").SpawnInstance_
objNewPort.Name = "Brother"
objNewPort.Protocol = 1
objNewPort.HostAddress = "10.12.34.90" '<<< ID WILL FILL IN THIS SECTION
objNewPort.PortNumber = "9100"
objNewPort.SNMPEnabled = False
objNewPort.Put_
'SETS PRINTER TO PORT.
Set objPrinter = objWMIService.Get _
("Win32_Printer").SpawnInstance_
objPrinter.DriverName = "Brother HL-1270N"
objPrinter.PortName = "Brother"
objPrinter.DeviceID = "Brother HL-1270N"
objPrinter.Location = "Front Office"
objPrinter.Network = True
objPrinter.Shared = False
'objPrinter.ShareName =
objPrinter.Put_
'SETS PRINTER AS DEFAULT.
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer Where Name = 'Brother HL-1270N'")
For Each objPrinter in colInstalledPrinters
objPrinter.SetDefaultPrinter()
next
,旧URL可能带有或不带有尾部斜杠。
一个例子是:
旧网址:product/
新网址:myshop.co.uk/product/category-name/sub-category-name/product-name
谁能告诉我实现这个目标的reg exp是什么?
答案 0 :(得分:0)
搜索(?<=product/)(?:[^/]+/)+(?=[^/]+/?$)
并替换为空字符串。