Gathering substrings from string

How do I gather the 1920 and 1080 from this string in a log file?

1920x1080 32bit @60Hz default

There are also 2 blank spaces before the 1920. I will be using these strings in a separate command to set the display resolution.

Thanks!

Using the space & ‘x’ characters as delimiter

(following text of last " " of preceding text of first "x" of it , preceding text of first " " of following text of first "x" of it) of " 1920x1080 32bit @60Hz default"

Using regex

(parenthesized part 1 of it, parenthesized part 2 of it) of matches (regex "^ +([0-9]+)x([0-9]+) .*$") of " 1920x1080 32bit @60Hz default"

Both will cope with varying length numeric strings

1 Like

This works perfectly thanks!