change text value where <cd> is



  • Hi …Below i give my note pad data…so in that i want to change only <cd> </cd> in total file…in file cd text have different text

    <SttlmAcct>
    <Id>
    <IBAN>IL30H</IBAN>
    </Id>
    <Tp>
    <Cd>0002</Cd>
    </Tp>
    <Ccy>NXJ</Ccy>
    <Nm>Nm</Nm>
    </SttlmAcct>

    like this i have almost 6800 lines…everytime manually i need to change only <Cd>009</C>…commanly in all cd’s

    can you tell me how to do this in notepad++ easily…pls



  • If you want to change anything on a line that starts with <cd> and ends with </cd> (case insensitive) to <cd>009</cd>, that’s easy.

    • Find = (?i-s)<cd>.*</cd>
    • Replace = <Cd>009</Cd>
    • mode = regular expression

    If you want something different, please read the below, and provide us with a complete description, properly formatted using the Markdown syntax described, so that we don’t have to guess what you really mean.

    -----
    FYI: I often add this to my response in regex threads, unless I am sure the original poster has seen it before. Here is some helpful information for finding out more about regular expressions, and for formatting posts in this forum (especially quoting data) so that we can fully understand what you’re trying to ask:

    This forum is formatted using Markdown, with a help link buried on the little grey ? in the COMPOSE window/pane when writing your post. For more about how to use Markdown in this forum, please see @Scott-Sumner’s post in the “how to markdown code on this forum” topic, and my updates near the end. It is very important that you use these formatting tips – using single backtick marks around small snippets, and using code-quoting for pasting multiple lines from your example data files – because otherwise, the forum will change normal quotes ("") to curly “smart” quotes (“”), will change hyphens to dashes, will sometimes hide asterisks (or if your text is c:\folder\*.txt, it will show up as c:\folder*.txt, missing the backslash). If you want to clearly communicate your text data to us, you need to properly format it.

    If you have further search-and-replace (“matching”, “marking”, “bookmarking”, regular expression, “regex”) needs, study this FAQ and the documentation it points to. Before asking a new regex question, understand that for future requests, many of us will expect you to show what data you have (exactly), what data you want (exactly), what regex you already tried (to show that you’re showing effort), why you thought that regex would work (to prove it wasn’t just something randomly typed), and what data you’re getting with an explanation of why that result is wrong. When you show that effort, you’ll see us bend over backward to get things working for you. If you need help formatting, see the paragraph above.

    Please note that for all regex and related queries, it is best if you are explicit about what needs to match, and what shouldn’t match, and have multiple examples of both in your example dataset. Often, what shouldn’t match helps define the regular expression as much or more than what should match.



  • Hi @PeterJones , thank u its working but i have same problem with another data i give below …so in that i need to change where “count” and where “amount”. count having different values and amount having different values. all count should be “count” : 008 and all “amount” : 000 …how to do this at a time total file.

    “count” : 002
    {
    “count”
    “amount” :033
    }
    “account” : 465454665465
    “end”
    “count” : 009
    {
    “count”
    “amount” :250
    }
    “account” : 465454665465
    “end”
    “count” : 012
    {
    “count”
    “amount” :556
    }
    “account” : 465454665465
    “end”
    “count” : 112
    {
    “count”
    “amount” :125
    }
    “account” : 465454665465
    “end”
    “count” : 056
    {
    “count”
    “amount” :500
    }
    “account” : 465454665465
    “end”
    “count” : 004
    {
    “count”
    “amount” :564
    }
    “account” : 465454665465
    “end”
    “count” : 235
    {
    “count”
    “amount” :569
    }
    “account” : 465454665465
    “end”



  • @rajesh-kumar said:

    thank u its working

    Glad to help.

    i have same problem with another data

    Then try a similar solution. Instead of searching for things inside of <cd>...</cd>, you’re looking for things that come after a prefix like "count": or "amount":. Even if you know nothing about regular expressions, you should be able to look at the regular expression I had defined before and have an attempt at it… it might not work right away, but you need to at least try. I’ll give you two more hints, because it’s buried a few links down in the regex documentation: the .* implies “any number of characters” in the regex, so you might want to use that when searching for any number of characters after your prefix. And the (?i-s) at the start of the regex is just making some settings to make it case insensitive, and to make sure that .* doesn’t wrap across lines. So using those two free gifts, you should be able to add in the permanent text that will look for one of your prefixes followed by any number of characters.

    Note that based on your response – where you ignored the advice about how to format a post so that we can read the data, and to avoid getting real quotes translated into smart quotes; and a post where you ignore my advice of “many of us will expect you to show what data you have (exactly), what data you want (exactly), what regex you already tried (to show that you’re showing effort)” – it’s appearing like you want us to do your work and research for you, rather than learning; at this point, it seems you are treating this forum like a free-consultancy board, rather than a forum to help you learn how to use the tool yourself. Please correct that mis-understanding of this forum, or you’ll quickly grow disappointed.

    Your first post got a free complete answer. For this one, I’m going to make you show effort (and I hope the other forum members do as well) before I give you any more complete answers. Before giving you any more explicit help, I will expect you to show that you’ve at least read the entirety of my first post – you can show this by re-posting your data, properly formatted; and by showing us what regex you tried (ie, a modified version of my original regex, showing that you’re looking for a prefix, followed by the rest of the line), what you think that regex should do, and show how your data didn’t change the way you expected when you ran your regex. This was all advice to you in the first post, which you apparently ignored. However, If you show even that much effort in your next reply – even if you haven’t availed yourself of reading the regex FAQ that was linked, and some of the pages linked in the FAQ – I’ll be willing to give more help.


Log in to reply