I am looking for a relevance which requires a check at two points?

Examples:
Hostname : ASDFG1234567890

  1. Need to identify two check were hostname starts with “AS” and 5/6th value as “G1” and rest anything.
  2. If the hostname starts with extra character for example “_” or “@”.

Try something like this - you can possibly do that with regex too:

q: (substring (0,2) of it = “AS” and substring (4,2) of it = “G1”) of "ASDFG1234567890"
A: True
T: 0.310 ms
I: singular boolean

// Using the ASCII character number ranges to evaluate what type of character it is.
q: ((it < 48 or (it > 57 and it < 65) or (it > 90 and it < 97) or it > 122)) of (it as hexadecimal as integer) of character 1 of "_ASDFG1234567890"
A: True
T: 0.221 ms
I: singular boolean

Some possible regex approaches

Q: exists matches (regex "(AS[A-Z][A-Z]G1)") of "ASDFG1234567890" 
A: True
T: 0.361 ms
I: singular boolean

Q: exists matches (regex "(([_]|[@])AS[A-Z][A-Z]G1)") of "_ASDFG1234567890" 
A: True
T: 0.274 ms
I: singular boolean

Another option for name that sarts with _ or @ that may also work

Q: (it starts with "_" or it starts with "@") of computer name 
A: False
T: 0.148 ms
I: singular boolean

Should a hostname starting with any single character match, or only “_” and “@” ? Should GASDFG1234567890 match?

If an “extra character” is at the start, are “G1” still in positions 5 & 6, or do they then shift to 6 & 7?

If yes to both, then I think a regex could be

regex "^.{0,1}AS.G1"

(Can’t test at the moment, though, typing on my phone). The regular expression tester at regex101.com is very useful for testing out regex patterns though.

1 Like

Ok, back at a computer and need a slight change above. The second “.” needs to be “.{2}”

q: exists matches (regex "^.{0,1}AS.{2}G1") of "ASDFG1234567890" 
A: True

q: exists matches (regex "^.{0,1}AS.{2}G1") of "-ASDFG1234567890" 
A: True

q: exists matches (regex "^.{0,1}AS.{2}G1") of "@ASDFG1234567890" 
A: True

q: exists matches (regex "^.{0,1}AS.{2}G1") of "GASDFG1234567890" 
A: True

q: exists matches (regex "^.{0,1}AS.{2}G1") of "GABDFG1234567890" 
A: False
    ( the "AS" is not matched)

q: exists matches (regex "^.{0,1}AS.{2}G1") of "GASDFGX234567890" 
A: False
     (the "G1" is not matched)

Explanation of the regex:

^        = Match from the start of the string
.{0,1}   = Match any character, 0 or 1 time
AS       = Match the literal string "AS"
.{2}     = Match any character, exactly 2 times
G1       = Match the literal string "G1"

Thanks @JasonWalker, I have one more query:

For example hostname “ABCDEF1234XYZ01/ABCDEG1234XYZ01/ABCDEGH234XYZ01” wanted to to fetch the result with the below scenario.

  1. Hostname should start with ABCDE
  2. 6th character of the hostname should be “F or G or H”
  3. contains %XYZ% after point 2.

‘ABCDE[FGH]%XYZ%’