I'm trying to replace the below text
"{print next
error
incorrect
err
}end"
to
"{print }end"
any I'm using (\{print)(.*?)(\}end)
but not working. Deleting everything from print and end will also work
You could use
\{print\h+\K[^{}]*\R(?=}end)
Explanation
\{
Match {
print\h+
match print and 1+ horizontal whitespace chars \K
Forget wat is matched so far [^{}]*\R
Match 0+ times any char except {
or }
and a newline (?=}end)
Positive lookahead, assert what is on the right is }end
In the replacement use an empty string.
I'm getting familiar day by day to Regex usage, so here I share my approach....
Find what: next[\s\S]+?(?=})
Replace with: nothing
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.