I want to extract ABC
and XZ
from the following string:
ABC XYZ
I tried this:
(ABC) (X(?:Y)Z)
But it extracts ABC
and XYZ
.
I want to extract ABC
and XZ
from the following string:
ABC XYZ
I tried this:
(ABC) (X(?:Y)Z)
But it extracts ABC
and XYZ
.
I'm not sure if this will be helpful to you at all, but I noticed you added a javascript tag.
If you want, you could try the following regex: https://regex101.com/r/JB3iNj/1
With the following code:
var myString = "ABC XYZ";
var myRegexp = /(ABC) (X)Y(Z)/g;
match = myRegexp.exec(myString);
var s1 = match[1]
var s2 = (match[2] + match[3])
console.log(s1 + " " + s2)