问题
I need to check occurrences where I have put one whitespace after a full-stop, and replace it by 2 spaces. I have the Regex for it, but Atom seems to call in invalid.
(?<=\.|\") {1,}(?=[a-zA-Z])
Conditions:
- 1 spaces after period.
- If period in with a closing double quote, then 1 space after the quote.
The above regex works perfectly for my conditions however Atom is not able to validate it. I need to use it for existing files.
回答1:
You may use
([."]) ([a-zA-Z])
and replace with $1 $2
. See the regex demo and a regex graph:
Details
([."])
- Group 1 (its value is referred to with$1
backreference from the replacement pattern):.
or"
\s
to match any whitespace)([a-zA-Z])
- Group 2 ($2
): an ASCII letter.
来源:https://stackoverflow.com/questions/56323075/regex-to-check-number-of-spaces-after-full-stop-strictly-2-required