I match a NULL value by regular expression and it is not empty string, how do I set the condition to detect it
Have you got an example of what you are trying to do in KM? Because the above looks rather complicated for what I suspect could be done in another, simpler, way.
It is still the same problem as last time.
I detect the presence of the image by several cases.
When the NULL value is matched it means there is an image in the clipboard.
If it is not matched, it means there is no image.
But I have no way to detect it in Keyboard Maestro.
Have you tried the "If" condition "clipboard does contain an image" or "clipboard does not contain an image"?
Yes. It is not a image, it is a list that cannot be directly identified, which was the problem last time.
It doesn’t matter. I just tried to solve it.
Yes -- sorry about that, I realised my mistake 5 minutes ago! It was your
it means there is an image in the clipboard
...that threw me.
Glad you've solved it!
When asking for this sort of help please always include the simplest possible test-case macro that demonstrates the problem – and/or a link to your regex101.com test page.
It's waay better to test than to guess.
(Keyboard Maestro Moderator)
There are four cases here:
a picture below the text (it is not a picture, but a file address)
a picture in the middle of the text
a direct copy of the picture without the text, i.e. blank, which I detect with
^$(to put all cases together, so I just replace blank with other cases)
just the text, without the picture (in this case, by
(? <=\n$). *|^$expression can't match any value)
The first three cases, you can match the NULL value, only the last case can't be matched, which means I just need to detect the NULL value to match whether the picture is copied (it's not a picture, but a file link)
I can't detect this value directly by
Search System Clipboard Using Regular Expression (ignoring case) method.
So I use another method
Search and Replace System Clipboard Using Regular Expression (ignoring case) to replace it first and then query it. It doesn't look very straightforward, but it works for me.
Detect NUL.kmmacros (11 KB)
My goal was to extract the image addresses from the script provided to me by @ComplexPoint. The process is complicated because I use a software called Eudic English dictionary, which is not in a regular format and cannot be read directly by the clipboard. But one thing is strange, when I drag the image directly to Keyboard Maestro, it can read the address of this image.I think there is a simpler way, but I don't know how to do it.
Here is the link to the entire question.
I still think you're going about this the wrong way.
From the clipboard data you supplied earlier, it looks like there will only be an image when there's an image link. So try searching for
"public.html作为数据": "<img src=\"file:///var/folders/
...or similar. If that's true -- image. If not -- no image.
Otherwise, I think it's confusion about regex101's use of NULL. I think they use that to indicate "the match group is an empty string" so you could try the usual KM regex->variables then test the variables with "If... is empty".