Can't find and replace text within multiple quotations
-
I’ve been bashing my head against this for a while. Regex is the answer, I’m sure, but my regex is very bad. This will be a no-brainer for many of you. Here is my problem:
I am trying to search this exact text in multiple config files (including the spaces and quotes). This is exactly as it appears:
"settingflag" "0"
And I want to replace it with:
"settingflag" "1"
Essentially, I just want to change that specific 0 to a 1 in these files. Would be great if it was the only instance of a zero in these config files, but unfortunately that’s not the case. The multiple quotes obviously mess up the search. What is the simple solution to this? I’ve messed around with regex but even when I’m doing what I am sure is correct (^“settingflag” “0”$), it fails to find the entire string.
Thanks for any help on this.
-
@Murderface-666 said in Can't find and replace text within multiple quotations:
I am trying to search this exact text
If it is exact text you are searching for then regex isn’t needed. You would do the search in “normal” mode, typing in the exact text.
The only reason to use regex is when the text (within the quotes) may change, the number of spaces between the 2 sections differs or the number changes.
Maybe you need to come back with more info if a “normal” search doesn’t work for you.
Terry
-
I’m confused. Why is this not as simple as:
Find:
"settingflag" "0"
Replace:
"settingflag" "1"
-
Well this is very weird and a little embarrassing. I’ve just realized that at some point, the text I copied and pasted for the search lost a bunch of the spaces, which is why it wasn’t finding it. I just kept pasting the incorrectly spaced text every time I tried, which of course resulted in the issue.
Not sure how it happened to begin with, but everything works as expected now. Thanks.
-
@Murderface-666
No problem. Let me be the first to say thanks for explaining what happened, essentially owning up.All too often we never hear back from the poster, so never know if we really helped or they figured it out, sometimes resulting in slapping forehead with hand.
Terry
-
-
Moderator restored the original post.
Deleting a post after there have been replies is highly discouraged. There is nothing sensitive in the original post, so the post has been restored to maintain the history of this conversation:
Don’t be embarrassed about having figured out the real problem: in internet help forums, there’s a whole category called “rubber duck debugging”, wherein just explaining the problem to someone else (ie, making your post) is enough to nudge your mind in the right direction, even without a reply – it’s nothing to be ashamed of. And thanks for letting us know you figured out your problem (so many times, people just go away after figuring it out, and never tell us whether we helped or whether we just acted as the rubber duck).
-