Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
import re
# this pattern matches things like "foo-bar" or "bar-baz"
pattern = "X(.+) Y(.+)"
string1 = "G00 X-13.50 Y15.25"
# returns Null if no match
matches = re.match(".*X(.+) Y(.+)",string1)
print(matches)
if matches:
# match indices start at 1
first_group_match = matches.group(1)
# abc
second_group_match = matches.group(2)
# def
print(first_group_match+" AND "+second_group_match)
Advertisements
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.
AcceptLearn more