Inserting text before and after regex

Hello
I want to inset text before and after a date - example.

str5="Royal coronation year and dob is 1952/12/14 - great year. Another
good year was 1966/01/01"
puts str5.match(/\b(\d\d\d\d)\/(\d\d)\/(\d\d)/)

So, what I would like is to put say "YEAR" before and "END" after each date found
in the given format. So, the final result would be...

"Royal coronation year and dob is YEAR 1952/12/14 END- great year. Another
good year was YEAR 1966/01/01 END"
Regards
philsivyerAsked:
Who is Participating?
 
Geert BormansConnect With a Mentor Information ArchitectCommented:
str5="Royal coronation year and dob is 1952/12/14 - great year. Another
good year was 1966/01/01"
puts str5.gsub(/\b(\d\d\d\d\/\d\d\/\d\d)/, 'YEAR \1 END')
0
 
philsivyerAuthor Commented:
Thanks
Welcome back - where have you been?
0
 
Geert BormansInformation ArchitectCommented:
busy
and spending the little time I had left for Experts Exchange in teh XSLT zone
I am happy that you missed me :-)
0
 
philsivyerAuthor Commented:
Now I know where you are - thanks!
0
 
Geert BormansInformation ArchitectCommented:
welcome
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.