问题
I am really having trouble with regex using notepad++:
For any single word following an equal sign (=), place what follows the equal sign in quotes.
eg: a = bcd becomes a = "bcd"
This is what I have but it is giving me problems:
s/=\([^" >][^ >]*\)/="\1"/g
* I am using the regex to search through a word document in Notepad++
回答1:
Try this:
Search: (=\s*)(\w+\b)
Replace: $1"$2"
回答2:
This should work
$searchText =~ s/(\w* *\= *)(\w*)/$1"$2"/g;
You should be specific about what is a word and what isn't and other constraints
回答3:
To place quotes around anything unquoted after equals in Notepad++ using a regex:
Find What: =\s*([^"]*)$
Replace With: = "\1"
来源:https://stackoverflow.com/questions/16380039/regex-matching-expression-notepad