Trim xml attribute
I have a large group of xml files that were generated to a specification where one attribute
dealerCustName=“This is the attribute there are many of them”
I need to be able to Trim the value of all of these attributes to 25 characters.
dealerCustName = “123456789012345678901234567890123456789”
needs to be this
dealerCustName = “1234567890123456789012345”
The attribute needs to be truncated to 25 chars regardless of the content.
One way would be thus:
Find what zone:
Replace with zone:
Search mode: Regular expression
If you can’t figure that out, just say so and it will be explained. :-D
guy038 last edited by
An other formulation could be :
ACTION Click on the
Replace Allbutton, exclusively
… and same remark as Scott’s one !
\Kin my regular expression at first as I played wit it. Then I remembered that Notepad++ has trouble sometimes with it when using the “walking replace” (definition: using Replace to walk through and selectively replace text). I think most people (especially regex newbies) prefer to walk through some replacements first to build confidence that a search expression is correct before hitting Replace All. Thus I tend to not propose
\Ksolutions here (I tend to capture everything leading up to where the
\Kwould be into a group, and then use that group at replacement time to re-insert the text).
Of course, maybe this is a case where
\Kwill work with the walking-replace; not sure, didn’t try. ;-)
@Scott-Sumner Beautiful! That is exactly what I was looking for! Is there a place where I can find syntax for these types of replacements?
Some good references relating specifically to Notepad++ are:
- general: http://docs.notepad-plus-plus.org/index.php/Regular_Expressions
- find-specific: http://www.boost.org/doc/libs/1_48_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html
- replace-specific: http://www.boost.org/doc/libs/1_48_0/libs/regex/doc/html/boost_regex/format/boost_format_syntax.html
Also, some other general references I like are:
Thanks again Scott.
You have been of great help.