Newbie question - search and replace with wildcard
-
Hi,
I’ve tried to find the solution for this question but I got stuck. Hopefully someone can help me out. I have a text file where I would like to make a search and replaceString to search for: “1” .* “1” where the .* can be anything but between two tabs and “1” . I find the strings with this to search for but feel free to correct me.
I would like to keep the data in the middle just change the second “1” to “6”
So: “1” “100” “1” would become “1” “100” “6”
And: “1” “99994” “1” would become “1” “99994” “6”Can someone please help me out ?!
Many thanks
Fredrik from Sweden. -
Try Regular expression search mode.
find:
(?-s)"1".*?"\K1(?=")
repl:6
I realize there is a lot going on in that find expression, for a newbie.
Reference the regular-expression information in our FAQ section.
-
@Fredrik-Konradsson said in Newbie question - search and replace with wildcard:
String to search for: “1” .* “1” where the .* can be anything
I should have stated that your first try at it was not bad, not bad, indeed! :-)
-
@Alan-Kilborn Ohh, many thanks. Saved my day! That I wouldn’t have figured out my self : ) Have a nice weekend.
-
Of course, for this one TMTOWTDI.
Here’s another, which might be more along the track you were originally going:
find:
(?-s)("1".*?)"1"
repl:${1}"6"
That one might be clearer.
But anyway, good that it is solved for you.
-
@Alan-Kilborn said in Newbie question - search and replace with wildcard:
find: (?-s)(“1”.*?)“1”
repl: ${1}“6”Many thanks! I really appriciate your help.