Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A gadget to enhance QM rx?
#1
Hi,

After a period of study and use, I found that QM does not support regular expressions completely. Some advanced regular expressions do not support 
 
 My current solution is to embed Powershell script code in QM. There is a problem: when processing a large number of files in a loop, the speed is very slow 
 
 Is there a better solution? Open source DLL? Third party regular widget? 
 Any suggestions and ideas are welcome

david
#2
The following command line enabled gadgets were found
Quote:Search using Perl Compatible Regular Expressions
Use group matching in replacement text
Supports Windows and Unix line endings
Unicode support
Accepts multiple search/replace arguments
Options may be provided in an options file
Scan for files
Preview mode
Line and full file matching modes

https://sites.google.com/site/regexreplace/
#3
The answer of ChatGPT:

What is the method to use PCRE2 regular expressions in Quick macros?
​​​​​​​
QM does not support PCRE2 regular expressions natively. However, it is possible to use PCRE2 regular expressions in QM by compiling the PCRE2 library as a dynamic link library (DLL) and then calling the library functions through QM's DLL command. You can write QM functions to wrap the PCRE2 DLL functions for use in QM scripts.
To use PCRE2 regular expressions in QM, you need to have the PCRE2 library and header files installed on your computer. Then, you need to compile the PCRE2 library as a DLL file. You can compile it using a compiler like Visual Studio, or you can use a pre-compiled DLL.
Once you have the PCRE2 DLL file, you can load and call its functions using QM's DLL command, as shown in the previous example. You can also create QM functions to provide a more user-friendly interface for using PCRE2 regular expressions in QM scripts.
Overall, while it requires some additional work to set up and use PCRE2 regular expressions in QM, it is possible and provides more powerful and flexible regular expression capabilities than QM's built-in regular expression functions.

How to use QM's dynamic link library (DLL) command to call a compiled PCRE2 dynamic link library?
 You can use QM's dynamic link library (DLL) command to call a precompiled PCRE2 dynamic link library. Here is a basic example:
 
Code:
Copy      Help
int hDll = dll.Open("pcre2.dll")  // Load the PCRE2 DLL and obtain a handle
string str = "Hello, world!"
dll.Call(hDll, "pcre2_match", "rRs", str, "Hello")  // Call the pcre2_match function of PCRE2 for matching
dll.Free(hDll)  // Release the DLL handle and free resources
This example assumes that the PCRE2 dynamic link library has been precompiled and saved as pcre2.dll on the local disk. First, load the PCRE2 DLL and obtain a handle by using the dll.Open function. Then, use the dll.Call function to call the pcre2_match function of PCRE2 for string matching. Finally, release the DLL handle and free resources with the dll.Free function.
Please note that this is just a basic example, and the specific implementation process may need to be adjusted based on the interface of the PCRE2 DLLand the syntax of QM's dynamic link library command.

ChatGPT seems to have little understanding of the QM language and the code is incorrect  Wink
#4
Can someone provide an example of calling the PCRE2 DLL function? Thank you in advance

PCRE2 dll down:


Attached Files
.zip   pcre2-16.dll.zip (Size: 119.39 KB / Downloads: 118)
#5
QM uses a very old PCRE version. LA uses new PCRE2. Both are not fully compatible with PowerShell, which probably uses .NET Regex.

In QM can be used C# code, and .NET Regex in it. If the speed is not very important.
#6
thank you


Forum Jump:


Users browsing this thread: 3 Guest(s)