Removing all leading xyz characters before capital letter

I have the following example from dataframe df$team where I would like to remove all xyz characters (in any formation) before the capital letter. I've tried str_remove option, gsub options however it removes all instances of xyz.

teams <- c("yLaval", "xyHershey", "xyzToronto", "xTexas")

Looking for: "Laval", "Hershey", "Toronto", "Texas"

Thank you in advance

solution found, needed to restore what captured using "\1"

sub("^.*?([A-Z])", "\1", team)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.