如何使用记事本++和正则表达式将所有空格删除到大括号中?
例如:
我有字符串 [单词1 单词2 单词3]我需要: [单词1单词2单词3]
谢谢
s++(?=[^[]*])
s++
matches any whitespace character (equal to [rntfv ])
++ Quantifier — Matches between one and unlimited times, as many times as possible, without giving back (possessive)
Positive Lookahead (?=[^[]*])
Assert that the Regex below matches
Match a single character not present in the list below [^[]*
* Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
[ matches the character [ literally (case sensitive)
] matches the character ] literally (case sensitive)
(?:[|G(?!^))[^]s]*Ks+
Non-capturing group (?:[|G(?!^))
1st Alternative [
[ matches the character [ literally (case sensitive)
2nd Alternative G(?!^)
G asserts position at the end of the previous match or the start of the string for the first match
Negative Lookahead (?!^)
Assert that the Regex below does not match
^ asserts position at start of the string
Match a single character not present in the list below [^]s]*
* Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
] matches the character ] literally (case sensitive)
s matches any whitespace character (equal to [rntfv ])
K resets the starting point of the reported match. Any previously consumed characters are no longer included in the final match
s+
matches any whitespace character (equal to [rntfv ])
+ Quantifier — Matches between one and unlimited times, as many times as possible, giving back as needed (greedy)