Replace string with wildcard in perl

I have string with various endings; however, they all have a substring in common in toward the end of the string,  @R2_
I want to search for anything with @R2_ in its ending and replace it with @R2_leaf
how do i do this in perl?  
MichelleLacyAsked:
Who is Participating?
 
ozoConnect With a Mentor Commented:
s/\@R[2@]_l?e?a?$/\@R2_leaf/ for @strings;
0
 
ozoCommented:
What part of the string is "toward the end of the string"?

s/\@R2_/\@R2_leaf/

And where is the wildcard?
0
 
MichelleLacyAuthor Commented:
the strings are either @R2_ or @R2_l or @R2_le or @R@_lea, I want to make them all @R2_leaf
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
MichelleLacyAuthor Commented:
the substrings are at the end of a much longer string
0
 
MichelleLacyAuthor Commented:
so would the complete command be  perl -pi.bak -e 's/\@R[2@]_|?e?a?$/\@R2_leaf/g' filename
0
 
ozoCommented:
if end of the strings means end of the lines, then yes
0
 
ozoConnect With a Mentor Commented:
Except that | should be l
0
 
MichelleLacyAuthor Commented:
after typing in the command i get the message "Quantifier follows nothing before HERE mark in regex m/\@R[2@]_|? << HERE e?a?$/ at -e line 1"

what does this mean?  I have seen in before while trying various replace methods, before submitting this question.
0
 
MichelleLacyAuthor Commented:
thanks.  it worked.
0
All Courses

From novice to tech pro — start learning today.