lines of file "C:\temp\ntp.conf"
# This is a line that should not be matched because no server in it
server ntp.ops.aa-cc.org # ntp
# server bad.ntp.local #This also should not match because it is commented out
server 10.254.254.233
server 10.254.254.231 prefer iburst burst minpoll 4 maxpoll 4
server ntp.ops.aa-cc1.org # ntp
server 1.rhel.pool.ntp.org prefer iburst burst minpoll 4 maxpoll 4
server 127.127.1.0 # local clock
server 10.254.254.232 prefer iburst burst minpoll 4 maxpoll 4
server 143.165.48.29 iburst burst minpoll 4 maxpoll 4
server 1.rhel.pool.ntp.org iburst burst minpoll 4 maxpoll 4
server 2.rhel.pool.ntp.org iburst burst minpoll 4 maxpoll 4
Filter to just the “server” lines:
lines starting with "server" of file "C:\temp\ntp.conf"
server ntp.ops.aa-cc.org # ntp
server 10.254.254.233
server 10.254.254.231 prefer iburst burst minpoll 4 maxpoll 4
server ntp.ops.aa-cc1.org # ntp
server 1.rhel.pool.ntp.org prefer iburst burst minpoll 4 maxpoll 4
server 127.127.1.0 # local clock
server 10.254.254.232 prefer iburst burst minpoll 4 maxpoll 4
server 143.165.48.29 iburst burst minpoll 4 maxpoll 4
server 1.rhel.pool.ntp.org iburst burst minpoll 4 maxpoll 4
server 2.rhel.pool.ntp.org iburst burst minpoll 4 maxpoll 4
Next up, there are a couple of ways of looking at it. If we look at “everything after the spaces after ‘server’, up to a space after the name/address”, we can represent that as
Q: (parenthesized parts 1 of matches(regex("^server[[:space:]]+([^[:space:]]+)")) of it) of lines starting with "server" of file "C:\temp\ntp.conf"
A: ntp.ops.aa-cc.org
A: 10.254.254.233
A: 10.254.254.231
A: ntp.ops.aa-cc1.org
A: 1.rhel.pool.ntp.org
A: 127.127.1.0
A: 10.254.254.232
A: 143.165.48.29
A: 1.rhel.pool.ntp.org
A: 2.rhel.pool.ntp.org
T: 64.227 ms
I: plural substring
If we look it strictly as “the alphanumeric symbols, “.”, or dash/hyphens only”, we could use the expression
Q: (parenthesized parts 1 of matches(regex("^server[[:space:]]+(([[:alnum:]]|\.|-|_)+)")) of it) of lines starting with "server" of file "C:\temp\ntp.conf"
A: ntp.ops.aa-cc.org
A: 10.254.254.233
A: 10.254.254.231
A: ntp.ops.aa-cc1.org
A: 1.rhel.pool.ntp.org
A: 127.127.1.0
A: 10.254.254.232
A: 143.165.48.29
A: 1.rhel.pool.ntp.org
A: 2.rhel.pool.ntp.org
T: 63.088 ms
I: plural substring
Or we could skip the regex altogether, if we assume exactly one space after "server ". As you’ve seen, Regular Expressions depend on OS libraries, while these purely Relevance-based queries are likely to be more reliable:
q: preceding texts of firsts " " of following texts of firsts "server " of lines starting with "server" of file "C:\temp\ntp.conf"
A: ntp.ops.aa-cc.org
A: 10.254.254.231
A: ntp.ops.aa-cc1.org
A: 1.rhel.pool.ntp.org
A: 127.127.1.0
A: 10.254.254.232
A: 143.165.48.29
A: 1.rhel.pool.ntp.org
A: 2.rhel.pool.ntp.org
T: 63.101 ms
I: plural substring
Or, assuming that we want the string containing a “.” from the line, and that there’s only one such string, we can split the line up by tabs and spaces (tab is %09 )
q: (substrings separated by " " of substrings separated by "%09" of it ) whose (it contains ".") of lines starting with "server" of file "C:\temp\ntp.conf"
A: ntp.ops.aa-cc.org
A: 10.254.254.233
A: 10.254.254.231
A: ntp.ops.aa-cc1.org
A: 1.rhel.pool.ntp.org
A: 127.127.1.0
A: 10.254.254.232
A: 143.165.48.29
A: 1.rhel.pool.ntp.org
A: 2.rhel.pool.ntp.org
T: 63.498 ms
I: plural substring
edit: edited the regexen to allow multiple spaces after “server”