'Find and Replace' question
Need lots of editing from say PR1=‘0066’ or PR1=‘3601’ or PR1=‘3722’ … to same, but without quotation marks and wise versa.
Is there any way to do it with help of find and replace?
taking your short description, you could use regular expression in find/replace.
which means regex is looking for numbers which are/aren’t encased by single quotes and must be prefixed by PR1= .
In replace put the number you want to have.
Thank you so much Claudia!
That code actually works and finds all the instances it supposed to.
But I have problems with replacement now…
It should be same numbers with same sequence, just without quotes - like, PR1=‘0066’ or PR1=‘3601’ or PR1=‘3722’… after replacement should be -> PR1=0066 or PR1=3601 or PR1=3722…
Is it possible to make find and replace to leave the same numbers after adding or deleting quotes?
Mb there is other way to add/delete quotes in sequence where PR1= is constant, but numbers are different and just randomly assigned?
you just wanna get rid of the single quotes?
PR1= and number should stay?
That`s correct. PR1=and number should stay for each instance of PR1=number1, PR1=number2 …PR1=numberN
not the most elegant but in find what use
and in replace with use backslash 2
you’re welcome - but if you really wanna see pure magic checkout
the regex tips from guy038 and the other regex gurus :-D
That`s my plan :)
Or even more simple :
If necessary, check the Match case option, if the case pr=1 may happen !
Due to the look-behind feature
(?<=PR1=), you cannot use the Replace button, successively and must, exclusively, use the Replace All button !!
For newby people, about regular expressions concept and syntax, begin with that article, in N++ Wiki :
In addition, you’ll find good documentation, about the Boost C++ Regex library, v1.55.0 ( similar to the PERL Regular Common Expressions, v5.8 ), used by
Notepad++, since its
6.0version, at the TWO addresses below :
The FIRST link explains the syntax, of regular expressions, in the SEARCH part
The SECOND link explains the syntax, of regular expressions, in the REPLACEMENT part
You may, also, look for valuable informations, on the sites, below :
Be aware that, as any documentation, it may contain some errors ! Anyway, if you detected one, that’s good news : you’re improving ;-))
Thank you so much for taking your time and answering in this theme!
Could you also help with reverse replacement: adding quotation marks before and after numbers (it`s always 4 numbers in a row preceding by PR1=) like PR1=0066 or PR1=3601 or PR1=3722 -> PR1=‘0066’ or PR1=‘3601’ or PR1=‘3722’
I would do it like this:
Note: Before text:
PR1='0123' PR1=7777 PR1='0000' PR1=3456
Case 1: PR1=‘1234’ —> PR1=1234 (remove quotes):
PR1=0123 PR1=7777 PR1=0000 PR1=3456
Case 2: PR1=1234 —> PR1=‘1234’ (add quotes):
PR1='0123' PR1='7777' PR1='0000' PR1='3456'
Case 3: PR1=‘1234’ —> PR1=1234 & at same time PR1=4321 —> PR1=‘4321’ (add and remove quotes at same time):
PR1=0123 PR1='7777' PR1=0000 PR1='3456'
For any of these cases, you do not have to use the Replace All button, although you may. Find Next and Replace combinations to selectively replace is fine.
@Scott-Sumner that`s amazing. Thank you very much for your help!