Search through whole line and change words with ize to ise using regex in Notepad++












1















I want to search all the words in a line/sentence and detect any word with ize and convert it to ise except for certain words listed.



Find: ^(?!size)(?!resize)(?!Belize)(?!Bizet)(?!Brize)(?!Pfizer)(?!assize)(?!baize)(?!bedizen)(?!citizen)(?!denizen)(?!filesize)(?!maize)(?!prize)(?!netizen)(?!seize)(?!wizen)(?!outsize)(?!oversize)(?!misprize)(?!supersize)(?!undersize)(?!unsized)(?!upsize)([a-zA-Z-s]+)ize



Replace: $1ise



So far all i get is the first word of the line with ize to work, or the last word with ize to work.



Example Organize to socialize whatever size.
To Organise to socialise whatever size.



Find (?i)(?!size|resize|Belize|so&so|unsized|upsize)(?<!w)(w+)ize

Replace $1ise


worked as intended. Capitalisation issues added (?i)










share|improve this question

























  • Could you please extend your example to a before/after case?

    – Dávid Laczkó
    Jan 2 at 21:30
















1















I want to search all the words in a line/sentence and detect any word with ize and convert it to ise except for certain words listed.



Find: ^(?!size)(?!resize)(?!Belize)(?!Bizet)(?!Brize)(?!Pfizer)(?!assize)(?!baize)(?!bedizen)(?!citizen)(?!denizen)(?!filesize)(?!maize)(?!prize)(?!netizen)(?!seize)(?!wizen)(?!outsize)(?!oversize)(?!misprize)(?!supersize)(?!undersize)(?!unsized)(?!upsize)([a-zA-Z-s]+)ize



Replace: $1ise



So far all i get is the first word of the line with ize to work, or the last word with ize to work.



Example Organize to socialize whatever size.
To Organise to socialise whatever size.



Find (?i)(?!size|resize|Belize|so&so|unsized|upsize)(?<!w)(w+)ize

Replace $1ise


worked as intended. Capitalisation issues added (?i)










share|improve this question

























  • Could you please extend your example to a before/after case?

    – Dávid Laczkó
    Jan 2 at 21:30














1












1








1








I want to search all the words in a line/sentence and detect any word with ize and convert it to ise except for certain words listed.



Find: ^(?!size)(?!resize)(?!Belize)(?!Bizet)(?!Brize)(?!Pfizer)(?!assize)(?!baize)(?!bedizen)(?!citizen)(?!denizen)(?!filesize)(?!maize)(?!prize)(?!netizen)(?!seize)(?!wizen)(?!outsize)(?!oversize)(?!misprize)(?!supersize)(?!undersize)(?!unsized)(?!upsize)([a-zA-Z-s]+)ize



Replace: $1ise



So far all i get is the first word of the line with ize to work, or the last word with ize to work.



Example Organize to socialize whatever size.
To Organise to socialise whatever size.



Find (?i)(?!size|resize|Belize|so&so|unsized|upsize)(?<!w)(w+)ize

Replace $1ise


worked as intended. Capitalisation issues added (?i)










share|improve this question
















I want to search all the words in a line/sentence and detect any word with ize and convert it to ise except for certain words listed.



Find: ^(?!size)(?!resize)(?!Belize)(?!Bizet)(?!Brize)(?!Pfizer)(?!assize)(?!baize)(?!bedizen)(?!citizen)(?!denizen)(?!filesize)(?!maize)(?!prize)(?!netizen)(?!seize)(?!wizen)(?!outsize)(?!oversize)(?!misprize)(?!supersize)(?!undersize)(?!unsized)(?!upsize)([a-zA-Z-s]+)ize



Replace: $1ise



So far all i get is the first word of the line with ize to work, or the last word with ize to work.



Example Organize to socialize whatever size.
To Organise to socialise whatever size.



Find (?i)(?!size|resize|Belize|so&so|unsized|upsize)(?<!w)(w+)ize

Replace $1ise


worked as intended. Capitalisation issues added (?i)







regex notepad++ regex-negation regex-lookarounds






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 3 at 3:06







user10246830

















asked Jan 2 at 20:56









user10246830user10246830

85




85













  • Could you please extend your example to a before/after case?

    – Dávid Laczkó
    Jan 2 at 21:30



















  • Could you please extend your example to a before/after case?

    – Dávid Laczkó
    Jan 2 at 21:30

















Could you please extend your example to a before/after case?

– Dávid Laczkó
Jan 2 at 21:30





Could you please extend your example to a before/after case?

– Dávid Laczkó
Jan 2 at 21:30












2 Answers
2






active

oldest

votes


















0














The regex ([a-zA-Z-s]+)ize has the whitespace marker in it (s) so it will will match anything beyond the word boundary. You might want to work with w and/or b to match only characters from the word where the "ize" is located. Additionally, you don't want the ^ at the beginning since this would match the start of the string.



Possible regex: (?!....your list....)(w+)ize



Example input: "Organize to socialize whatever size."



Found matches: "Organize" and "socialize", but not "size", see https://regex101.com/r/UIfoa8/1



After that you can use your replacement $1ise to replace the found string with the captured group and "ise".






share|improve this answer
























  • Thanks for the help, so close. I managed to get it. (?<!w) was needed.

    – user10246830
    Jan 3 at 1:02













  • regex101.com/r/UIfoa8/2

    – user10246830
    Jan 3 at 1:11











  • (?i) added regex101.com/r/UIfoa8/3

    – user10246830
    Jan 3 at 2:35



















0














Make a Whitelist Array




  • Make the excluded words (whitelist) an array of strings


  • .split(' ') the text being searched through (searchStr) into an array

  • then .map() through each word of the array


    • using .indexOf() to compare a word vs. the whitelist

    • using .test() to see if it's a x+"ize" word to .replace()



  • Once the searchArray is complete, .join() it into a string (resultString).




Demo



"organize", "mesmerized", "socialize", and "baptize" was mixed into the search string of some whitelist words




var searchStr = `organize Belize Bizet mesmerized Brize Pfizer assize baize bedizen citizen denizen filesize socialize maize prize netizen seize wizen outsize baptize`;

var whitelist = ["size", "resize", "Belize", "Bizet", "Brize", "Pfizer", "assize", "baize", "bedizen", "citizen", "denizen", "filesize", "maize", "prize", "netizen", "seize", "wizen", "outsize", "oversize", "misprize", "supersize", "undersize", "unsized", "upsize"];

var searchArray = searchStr.split(' ').map(function(word) {
var match;
if (whitelist.indexOf(word) !== -1) {
match = word;
} else if (/([a-z]+?)ize/i.test(word)) {
match = word.replace(/([a-z]+?)ize/i, '$1ise');
} else {
match = word;
}
return match;
});

var resultString = searchArray.join(', ');

console.log(resultString);








share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54013075%2fsearch-through-whole-line-and-change-words-with-ize-to-ise-using-regex-in-notepa%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    The regex ([a-zA-Z-s]+)ize has the whitespace marker in it (s) so it will will match anything beyond the word boundary. You might want to work with w and/or b to match only characters from the word where the "ize" is located. Additionally, you don't want the ^ at the beginning since this would match the start of the string.



    Possible regex: (?!....your list....)(w+)ize



    Example input: "Organize to socialize whatever size."



    Found matches: "Organize" and "socialize", but not "size", see https://regex101.com/r/UIfoa8/1



    After that you can use your replacement $1ise to replace the found string with the captured group and "ise".






    share|improve this answer
























    • Thanks for the help, so close. I managed to get it. (?<!w) was needed.

      – user10246830
      Jan 3 at 1:02













    • regex101.com/r/UIfoa8/2

      – user10246830
      Jan 3 at 1:11











    • (?i) added regex101.com/r/UIfoa8/3

      – user10246830
      Jan 3 at 2:35
















    0














    The regex ([a-zA-Z-s]+)ize has the whitespace marker in it (s) so it will will match anything beyond the word boundary. You might want to work with w and/or b to match only characters from the word where the "ize" is located. Additionally, you don't want the ^ at the beginning since this would match the start of the string.



    Possible regex: (?!....your list....)(w+)ize



    Example input: "Organize to socialize whatever size."



    Found matches: "Organize" and "socialize", but not "size", see https://regex101.com/r/UIfoa8/1



    After that you can use your replacement $1ise to replace the found string with the captured group and "ise".






    share|improve this answer
























    • Thanks for the help, so close. I managed to get it. (?<!w) was needed.

      – user10246830
      Jan 3 at 1:02













    • regex101.com/r/UIfoa8/2

      – user10246830
      Jan 3 at 1:11











    • (?i) added regex101.com/r/UIfoa8/3

      – user10246830
      Jan 3 at 2:35














    0












    0








    0







    The regex ([a-zA-Z-s]+)ize has the whitespace marker in it (s) so it will will match anything beyond the word boundary. You might want to work with w and/or b to match only characters from the word where the "ize" is located. Additionally, you don't want the ^ at the beginning since this would match the start of the string.



    Possible regex: (?!....your list....)(w+)ize



    Example input: "Organize to socialize whatever size."



    Found matches: "Organize" and "socialize", but not "size", see https://regex101.com/r/UIfoa8/1



    After that you can use your replacement $1ise to replace the found string with the captured group and "ise".






    share|improve this answer













    The regex ([a-zA-Z-s]+)ize has the whitespace marker in it (s) so it will will match anything beyond the word boundary. You might want to work with w and/or b to match only characters from the word where the "ize" is located. Additionally, you don't want the ^ at the beginning since this would match the start of the string.



    Possible regex: (?!....your list....)(w+)ize



    Example input: "Organize to socialize whatever size."



    Found matches: "Organize" and "socialize", but not "size", see https://regex101.com/r/UIfoa8/1



    After that you can use your replacement $1ise to replace the found string with the captured group and "ise".







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jan 2 at 22:14









    ProgmanProgman

    6,52532037




    6,52532037













    • Thanks for the help, so close. I managed to get it. (?<!w) was needed.

      – user10246830
      Jan 3 at 1:02













    • regex101.com/r/UIfoa8/2

      – user10246830
      Jan 3 at 1:11











    • (?i) added regex101.com/r/UIfoa8/3

      – user10246830
      Jan 3 at 2:35



















    • Thanks for the help, so close. I managed to get it. (?<!w) was needed.

      – user10246830
      Jan 3 at 1:02













    • regex101.com/r/UIfoa8/2

      – user10246830
      Jan 3 at 1:11











    • (?i) added regex101.com/r/UIfoa8/3

      – user10246830
      Jan 3 at 2:35

















    Thanks for the help, so close. I managed to get it. (?<!w) was needed.

    – user10246830
    Jan 3 at 1:02







    Thanks for the help, so close. I managed to get it. (?<!w) was needed.

    – user10246830
    Jan 3 at 1:02















    regex101.com/r/UIfoa8/2

    – user10246830
    Jan 3 at 1:11





    regex101.com/r/UIfoa8/2

    – user10246830
    Jan 3 at 1:11













    (?i) added regex101.com/r/UIfoa8/3

    – user10246830
    Jan 3 at 2:35





    (?i) added regex101.com/r/UIfoa8/3

    – user10246830
    Jan 3 at 2:35













    0














    Make a Whitelist Array




    • Make the excluded words (whitelist) an array of strings


    • .split(' ') the text being searched through (searchStr) into an array

    • then .map() through each word of the array


      • using .indexOf() to compare a word vs. the whitelist

      • using .test() to see if it's a x+"ize" word to .replace()



    • Once the searchArray is complete, .join() it into a string (resultString).




    Demo



    "organize", "mesmerized", "socialize", and "baptize" was mixed into the search string of some whitelist words




    var searchStr = `organize Belize Bizet mesmerized Brize Pfizer assize baize bedizen citizen denizen filesize socialize maize prize netizen seize wizen outsize baptize`;

    var whitelist = ["size", "resize", "Belize", "Bizet", "Brize", "Pfizer", "assize", "baize", "bedizen", "citizen", "denizen", "filesize", "maize", "prize", "netizen", "seize", "wizen", "outsize", "oversize", "misprize", "supersize", "undersize", "unsized", "upsize"];

    var searchArray = searchStr.split(' ').map(function(word) {
    var match;
    if (whitelist.indexOf(word) !== -1) {
    match = word;
    } else if (/([a-z]+?)ize/i.test(word)) {
    match = word.replace(/([a-z]+?)ize/i, '$1ise');
    } else {
    match = word;
    }
    return match;
    });

    var resultString = searchArray.join(', ');

    console.log(resultString);








    share|improve this answer




























      0














      Make a Whitelist Array




      • Make the excluded words (whitelist) an array of strings


      • .split(' ') the text being searched through (searchStr) into an array

      • then .map() through each word of the array


        • using .indexOf() to compare a word vs. the whitelist

        • using .test() to see if it's a x+"ize" word to .replace()



      • Once the searchArray is complete, .join() it into a string (resultString).




      Demo



      "organize", "mesmerized", "socialize", and "baptize" was mixed into the search string of some whitelist words




      var searchStr = `organize Belize Bizet mesmerized Brize Pfizer assize baize bedizen citizen denizen filesize socialize maize prize netizen seize wizen outsize baptize`;

      var whitelist = ["size", "resize", "Belize", "Bizet", "Brize", "Pfizer", "assize", "baize", "bedizen", "citizen", "denizen", "filesize", "maize", "prize", "netizen", "seize", "wizen", "outsize", "oversize", "misprize", "supersize", "undersize", "unsized", "upsize"];

      var searchArray = searchStr.split(' ').map(function(word) {
      var match;
      if (whitelist.indexOf(word) !== -1) {
      match = word;
      } else if (/([a-z]+?)ize/i.test(word)) {
      match = word.replace(/([a-z]+?)ize/i, '$1ise');
      } else {
      match = word;
      }
      return match;
      });

      var resultString = searchArray.join(', ');

      console.log(resultString);








      share|improve this answer


























        0












        0








        0







        Make a Whitelist Array




        • Make the excluded words (whitelist) an array of strings


        • .split(' ') the text being searched through (searchStr) into an array

        • then .map() through each word of the array


          • using .indexOf() to compare a word vs. the whitelist

          • using .test() to see if it's a x+"ize" word to .replace()



        • Once the searchArray is complete, .join() it into a string (resultString).




        Demo



        "organize", "mesmerized", "socialize", and "baptize" was mixed into the search string of some whitelist words




        var searchStr = `organize Belize Bizet mesmerized Brize Pfizer assize baize bedizen citizen denizen filesize socialize maize prize netizen seize wizen outsize baptize`;

        var whitelist = ["size", "resize", "Belize", "Bizet", "Brize", "Pfizer", "assize", "baize", "bedizen", "citizen", "denizen", "filesize", "maize", "prize", "netizen", "seize", "wizen", "outsize", "oversize", "misprize", "supersize", "undersize", "unsized", "upsize"];

        var searchArray = searchStr.split(' ').map(function(word) {
        var match;
        if (whitelist.indexOf(word) !== -1) {
        match = word;
        } else if (/([a-z]+?)ize/i.test(word)) {
        match = word.replace(/([a-z]+?)ize/i, '$1ise');
        } else {
        match = word;
        }
        return match;
        });

        var resultString = searchArray.join(', ');

        console.log(resultString);








        share|improve this answer













        Make a Whitelist Array




        • Make the excluded words (whitelist) an array of strings


        • .split(' ') the text being searched through (searchStr) into an array

        • then .map() through each word of the array


          • using .indexOf() to compare a word vs. the whitelist

          • using .test() to see if it's a x+"ize" word to .replace()



        • Once the searchArray is complete, .join() it into a string (resultString).




        Demo



        "organize", "mesmerized", "socialize", and "baptize" was mixed into the search string of some whitelist words




        var searchStr = `organize Belize Bizet mesmerized Brize Pfizer assize baize bedizen citizen denizen filesize socialize maize prize netizen seize wizen outsize baptize`;

        var whitelist = ["size", "resize", "Belize", "Bizet", "Brize", "Pfizer", "assize", "baize", "bedizen", "citizen", "denizen", "filesize", "maize", "prize", "netizen", "seize", "wizen", "outsize", "oversize", "misprize", "supersize", "undersize", "unsized", "upsize"];

        var searchArray = searchStr.split(' ').map(function(word) {
        var match;
        if (whitelist.indexOf(word) !== -1) {
        match = word;
        } else if (/([a-z]+?)ize/i.test(word)) {
        match = word.replace(/([a-z]+?)ize/i, '$1ise');
        } else {
        match = word;
        }
        return match;
        });

        var resultString = searchArray.join(', ');

        console.log(resultString);








        var searchStr = `organize Belize Bizet mesmerized Brize Pfizer assize baize bedizen citizen denizen filesize socialize maize prize netizen seize wizen outsize baptize`;

        var whitelist = ["size", "resize", "Belize", "Bizet", "Brize", "Pfizer", "assize", "baize", "bedizen", "citizen", "denizen", "filesize", "maize", "prize", "netizen", "seize", "wizen", "outsize", "oversize", "misprize", "supersize", "undersize", "unsized", "upsize"];

        var searchArray = searchStr.split(' ').map(function(word) {
        var match;
        if (whitelist.indexOf(word) !== -1) {
        match = word;
        } else if (/([a-z]+?)ize/i.test(word)) {
        match = word.replace(/([a-z]+?)ize/i, '$1ise');
        } else {
        match = word;
        }
        return match;
        });

        var resultString = searchArray.join(', ');

        console.log(resultString);





        var searchStr = `organize Belize Bizet mesmerized Brize Pfizer assize baize bedizen citizen denizen filesize socialize maize prize netizen seize wizen outsize baptize`;

        var whitelist = ["size", "resize", "Belize", "Bizet", "Brize", "Pfizer", "assize", "baize", "bedizen", "citizen", "denizen", "filesize", "maize", "prize", "netizen", "seize", "wizen", "outsize", "oversize", "misprize", "supersize", "undersize", "unsized", "upsize"];

        var searchArray = searchStr.split(' ').map(function(word) {
        var match;
        if (whitelist.indexOf(word) !== -1) {
        match = word;
        } else if (/([a-z]+?)ize/i.test(word)) {
        match = word.replace(/([a-z]+?)ize/i, '$1ise');
        } else {
        match = word;
        }
        return match;
        });

        var resultString = searchArray.join(', ');

        console.log(resultString);






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 3 at 2:54









        zer00nezer00ne

        25.3k32546




        25.3k32546






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54013075%2fsearch-through-whole-line-and-change-words-with-ize-to-ise-using-regex-in-notepa%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

            SQL update select statement

            'app-layout' is not a known element: how to share Component with different Modules