How to find and replace the word in notepad++



  • Sample:
    strcpy(p_add.arr,pname);
    strcpy(p_name,p_show.arr);
    strcpy(p_name.arr,p_name2.arr);

    To Find:
    strcpy(.arr,.arr)—i Have facing the error “0 hits showing” but will be there like in sample.

    To Replace:
    strcpy((char ).arr,(char ).arr).

    I have to add the (char *) prefix in the array variables.So kindly provide the command in notepad++.



  • @S-Balaji

    It IS rather a tricky one, but give this a try:

    Find what box: strcpy\((.*?),
    Replace with box: strcpy\(\(char *\)$1,\(char *\)
    Match case checkbox: ticked
    Search mode radiobutton: Regular expression

    It might need to be made more “restrictive”, but I think the above works for what you’ve shown as data.

    The key part that people might miss is that you need to escape the parentheses EVERYWHERE they appear.



  • @S-Balaji

    Of course, it may be prudent to limit the scope of the .*? part by adding a leading (?-s):

    Revised Find what box: (?-s)strcpy\((.*?),

    Also, I said:

    escape the parentheses EVERYWHERE…

    I should have said:

    “escape the literal parentheses EVERYWHERE…”

    The parentheses in these substructs are not the literal ones: (?-s) and (.*?)

    Sorry for any confusion. :-)


Log in to reply