Notepad++ Regex Find/Replace Using Look Behind not Working

前端 未结 1 1365
一生所求
一生所求 2020-12-21 12:56

I have the following CSS markup.

.previous-container{
    float:left;
}
.primary-commands {
    float:right;
}

Using the regex syntax searc

相关标签:
1条回答
  • 2020-12-21 13:28

    Based on comments to the original question here are some work-arounds that solved my problem.

    Option #1

    Replace the lookbehind portion of the regex statement (?<=[\s,;]) with a simple non-lookbehind group matching statement such as ([\s,;]). This will continue to limit search results to strings beginning with the specified characters in the lookbehind. The only caveat is that in my replacement string e.g. $1 $2 I would need to leave out the undesired matched characters that should not be a part of the replacement string.

    Option #2

    Use the "Replace All" button. It will perform replacements correctly when using a positive lookbehind in your regex statement as opposed to using the "Replace" button for single replacement.

    I went with Options #1 only because it achieves what I need while allowing me to still perform a single replacement at a time. With larger documents I don't want to use "Replace All" until I have thoroughly tested my regex expression.

    0 讨论(0)
提交回复
热议问题