notepad++ regular expression remove all text between curly brackets
Solution 1
Newer version of Notepad++ supports multi-line matching (I am now using 6.1.3)
In the Find/Replace dialog, next to the "Regular Expression" radio button, there is a checkbox called ". matches newline" which means multi-line matching.
Then, use \{.*?\}
(which is a ungreedy match) to achieve what you want.
Beware that it does not match braces for you. For example
foo {
bar {
blabalbla
}
xxx {
yyy
}
}
will give you
foo {}
xxx {
yyy
}
}
(I believe there are other questions in SO about brace matching in regex, you may have a look, though I wonder if they will work in notepad++)
Solution 2
You should be fine when you just replace \{[^{}]+\}
with {}
, repeatedly...
Solution 3
Try
(?<=\{)[^}]+(?=\})
this will match anything that falls between { and }
Comments
-
ehmad11 about 4 years
function get_last_word($sentance){ $wordArr = explode(' ', $sentance); $last_word = trim($wordArr[count($wordArr) - 1]); runDebug( __FILE__, __FUNCTION__, __LINE__, "Sentance: $sentance. Last word:$last_word",4); return $last_word; }
i want to remove all text between {} result should be:
function get_last_word($sentance){}
i have tried
{+.*}
and its working only when curly brackets are on same line