Reputation: 995
I'm trying to find all white spaces in string defined by begining as "jpeg" and ending with 600), in order to replace them with "_" but how do I catch all the \s in the string?
I'm working on sublime text editor / notepad++
I tried:
^jpeg.*(\s).*600\)$
Thanks for the help Example of text that is being edited:
# CHART: Share of persons living at risk of poverty or social exclusion ====
df <- S3R0004_M3080242 %>%
mutate(LAIKOTARPIS=parse_date_time(LAIKOTARPIS, "y"))
jpeg("./figures/Share of persons living at risk of poverty or social exclusion.jpeg", width = 9, height = 6, units = 'in', res = 600)
ggplot(data = df, aes(x=LAIKOTARPIS, y=obsValue)+
Upvotes: 0
Views: 105
Reputation: 627087
You may use
Find what: (?:\G(?!\A)|jpeg\("(?=[^"]*"[^)]*600\)))[^\s"]*\K\s+
Replace With: _
See the regex demo.
Details
(?:\G(?!\A)|jpeg\("(?=[^"]*"[^)]*600\)))
- matches either
\G(?!\A)
- the end of the preceding match|
- or jpeg\("(?=[^"]*"[^)]*600\))
- jpeg("
followed with any 0+ chars other than "
(with [^"]*
), then "
and then any 0+ chars other than )
and then 600)
[^\s"]*
- matches and consumes 0+ chars other than whitespace and "
\K
- match reset operator, the text matched before is cleared from the match buffer\s+
- 1+ whitespaces (they will be replaced).Upvotes: 1