I have the following conditions for my regex :
When the string is not empty it should contain the word “internal”
So in other words :
"<link linktype='internal' id='{F88AE8AE-69C4-4E31-95BF-73B110FEE63A}' />" --> OK
"<link linktype='external' id='{F88AE8AE-69C4-4E31-95BF-73B110FEE63A}' />" --> NOK
"test" --> NOK
"" --> OK
I know that an empty string can be checked with : ^$
Or a non empty string with : ^\s*\S
and my internal check simply as : linktype=\'internal\' (for example)
Bringing them together is the hard part. I’ve been stuck on this, but it doesn’t do as expected :
(?(?=^\s*\S)linktype=\"internal\"|^$)
Can anyone help ?
You could try
(^$)|(^.*linktype=\"internal\".*$)Either the empty string, or a string with the text
linktype="internal".