-1

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++

  • Are you saying you're using Perl style regular expressions in notepad++, or that you're using notepad++ to create a perl script? – phatfingers May 05 '13 at 00:21
  • Your specs and results don't match. You said, "place what follows the equal sign in quotes," but there's a whitespace after the "=" in `a = bcd` that your desired result doesn't include. Did you mean "place non-whitespace characters following the equal sign in in quotes" or place all equal-sign-following characters within quotes? – Kenosis May 05 '13 at 00:22
  • If you need to provide more information about your question, update your question. Don't ask the same question three times! – ikegami May 05 '13 at 00:29
  • actually that other post is a completely different question. – Bob Smithsfield May 05 '13 at 00:30
  • [No, it's really not](http://stackoverflow.com/questions/16379732/perl-regex-assistance). You've got three posts asking the same two related questions, all of which are "subpar". – ikegami May 05 '13 at 00:34

3 Answers3

1

Try this:

Search: (=\s*)(\w+\b)
Replace: $1"$2"

Bohemian
  • 412,405
  • 93
  • 575
  • 722
0

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

aaronman
  • 18,343
  • 7
  • 63
  • 78
0

To place quotes around anything unquoted after equals in Notepad++ using a regex:

Find What: =\s*([^"]*)$ Replace With: = "\1"

phatfingers
  • 9,770
  • 3
  • 30
  • 44