$re = '/\s+(-[0-9A-Za-z]+|--[A-Za-z0-9][\w-]+)/m';
$str = 'ignores position args
ignores-this _and_this _2 but-not -a -xvzf -4 -6 -Targ
ignores-echo -----------
ignores-mistaken --a did-you-mean -a
--3-2-pulldown
--3gpp-scan
--64
--802_3-sap
--802_3-type
--90
--abi-call0
--action1
--action9
--appData
--assume-utf16be
--assume-utf16le
--authValue
--aws-sigv4
--background_compression
--btf_encode
--cipherText
--Complain
--contains_enumerator
--data_replicas
--disable-pcre2-8
--disable-pcre2grep-callout
--disable-pcre2grep-callout-fork
--disable-pcre2grep-jit
--dns-ipv4-addr
--dns-ipv6-addr
--do-0x20-encode
--do-x20-encode
--dualprime-mpeg2
--eccpoint-L
--enable-ebcdic-nl25
--enable-never-backslash-C
--enable-pcre2-16
--enable-pcre2-32
--enable-pcre2grep-libbz2
--enable-pcre2grep-libz
--enable-pcre2test-libedit
--enable-pcre2test-libreadline
--entityPath
--expect100-timeout
--exportedData
--filter-A
--filter-AAAA
--filterwin2k
--force-ipv4
--force-ipv6
--force-R5
--force-V4
--Foreground
--fwdownload-mode3
--fwdownload-mode3-max
--fwdownload-mode7
--gb18030
--GBR
--hostpubmd5
--hostpubsha256
--http0
--http1
--http2
--http2-prior-knowledge
--http3
--http3-only
--ignoreDefinites
--importData
--Include
--intra_dc_prec
--ip6
--ip6-destination
--ip6-destination-port
--ip6-dport
--ip6-dst
--ip6-icmp-type
--ip6-proto
--ip6-protocol
--ip6-source
--ip6-source-port
--ip6-sport
--ip6-src
--ip6-tclass
--ipv4
--ipv6
--Iraw
--Istdin
--Istdout
--jsonPolicy
--keep-utf16
--keyPath
--lang_exclude
--Lc
--Lee
--linearize-pass1
--Lmac2
--Ln
--logData
--log-ip6
--Lx
--mirror-above-4G
--mirror-below-4G
--netfilter6
--no-0x20-encode
--no3d
--no-altscan-mpeg2
--no-D
--no-dhcpv4-interface
--no-dummy-svcd-SOF
--nr_methods
--numBytes
--Numeric
--nvPath
--oauth2-bearer
--omit_journal_replay
--output-Z1
--output-Z2
--p12-charset
--pathList
--pathOfKeyToDuplicate
--pcrIndex
--pcrList
--pcrLog
--pcrValue
--plainText
--policyPath
--policyRef
--post301
--post302
--post303
--prefer-ata12
--print0
--PROG-option
--proxy1
--proxy-http2
--proxy-tls13-ciphers
--proxy-tlsv1
--publicKey
--publicKeyPath
--qualifyingData
--quiet-dhcp6
--quoteInfo
--readimpliesX
--reduction-2x2
--reduction-4x4
--replay_journal_only
--searchPath
--seek_bytes
--set-recommended-min_free_kbytes
--S-force
--size_bytes
--socks4
--socks4a
--socks5
--socks5-basic
--socks5-gssapi
--socks5-gssapi-nec
--socks5-gssapi-service
--socks5-hostname
--sslv2
--sslv3
--tls13-ciphers
--tlsv1
--tpm2
--tpm2bPrivate
--tpm2bPublic
--type_trans
--type_transition
--UCS-2
--Version
--warning-exit-0
--Wext
--with-pcre2grep-bufsize
--with-pcre2grep-max-bufsize
--with-PROG
--Wnp
--Wp
--x11
--x32
--x509certData';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php