'Find and Replace' question
-
you just wanna get rid of the single quotes?
PR1= and number should stay?Cheers
Claudia -
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
(?<=PR1=)(')(\d+)(')and in replace with use backslash 2
\2Cheers
Claudia -
@Claudia-Frank said:
(?<=PR1=)(')(\d+)(')and in replace with use backslash 2
\2Cheers
ClaudiaThank you so so much! Pure magic! :)
-
you’re welcome - but if you really wanna see pure magic checkout
the regex tips from guy038 and the other regex gurus :-DCheers
Claudia -
That`s my plan :)
-
Hello @oleg-nemchenko, @claudia-frank and All,
Or even more simple :
SEARCH
(?<=PR1=)'(\d+)'REPLACE
\1Notes :
-
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 !!
Cheers,
guy038
P.S. :
For newby people, about regular expressions concept and syntax, begin with that article, in N++ Wiki :
http://docs.notepad-plus-plus.org/index.php/Regular_Expressions
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 its6.0version, at the TWO addresses below :http://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html
http://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/format/boost_format_syntax.html
-
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 :
http://www.regular-expressions.info
http://perldoc.perl.org/perlre.html
Be aware that, as any documentation, it may contain some errors ! Anyway, if you detected one, that’s good news : you’re improving ;-))
-
-
Hello @guy038,
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=3456Case 1: PR1=‘1234’ —> PR1=1234 (remove quotes):
Find-what zone:
(?-i)PR1='(\d{4})'
Replace-with zone:PR1=\1
After text:PR1=0123 PR1=7777 PR1=0000 PR1=3456Case 2: PR1=1234 —> PR1=‘1234’ (add quotes):
Find-what zone:
(?-i)PR1=(\d{4})
Replace-with zone:PR1='\1'
After text: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):
Find-what zone:
(?-i)PR1=(')?(\d{4})(')?
Replace-with zone:PR1=(?1:')\2(?3:')
After text: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!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login