regex - replacing all behind my matched string - gsub -


i'm new string manipulations in r. have case in i'm using several matched replacements in foor loop, , has rely on gsub.

now have string (illustrative example), "today great day"

in want use pattern "today is" only, , replace "my value"

but metacharacters need select rest of string?

my try

gsub("today is+.", "my value", myobject) 

now selects 1 value after "today is", how can make run way?

use capture-class grouping parens in pattern, , refer them \\<n> in replacement, , think need swap order of .+ in pattern:

> gsub("(today is)(.+)", "my value\\2", "today great day") [1] "my value great day" 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -