Search code examples
textreplacenotepadstac

Editing a specific place with notepad++


I need to replace a text in Notepad++. How can i do?

Text:

(1, 1, 'qweq123we123'),
(2, 1, 'qwe5qw123e42'),
(3, 1, 'qweq1233we61'),
(4, 1, 'qwe41qdw613e'),
(5, 1, 'qweq12f3w41e'),
(6, 1, 'qw21233eaqwe'),
(7, 1, 'qw5123ge3qwe'),

Replaced Text:

{"id":1,"ilid":1,"qweq123we123"}
{"id":1,"ilid":2,"qwe5qw123e42"}
{"id":1,"ilid":3,"qweq1233we61"}
{"id":1,"ilid":4,"qwe41qdw613e"}
{"id":1,"ilid":5,"qweq12f3w41e"}
{"id":1,"ilid":6,"qw21233eaqwe"}
{"id":1,"ilid":7,"qw5123ge3qwe"}

separately, i want to convert the result from qw5123ge3qwe to QW5123GE3QWE.

i searched on youtube and stackoverflow but could not find anything


Solution

  • You can use a regex search and replace. regex101.com

    Search String:

    \(([0-9]{1,}), ([0-9]{1,}), '([\u0600-\u06FF]{1,})'\)
    

    Replace:

    {"id":\1,"ilid":\2,"\U\3"}
    

    \1 \2 \3 are tied to the ([]{1,}) content. The \U makes anything after it to be uppercase.

    [0-9] means any number between 0-9 (single character)

    [0A-z0-9] means any number between 0-9 and any character between a-z including the different cases

    {1,} this means it must have at least 1 character matching. Everything is done on a single character basis, so if the number is larger than 9 e.g. 10 this is 2 characters a '1' + '0', you could restrict the number of characters by doing something like {1,7}

    ** [\u0600-\u06FF] ** add as an edit per eyuq's comment below