Path: ...!feeds.phibee-telecom.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Richard Owlett Newsgroups: comp.editors Subject: Re: Confused first time Kate user Date: Wed, 3 Jul 2024 07:22:14 -0500 Organization: A noiseless patient Spider Lines: 92 Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 03 Jul 2024 14:22:16 +0200 (CEST) Injection-Info: dont-email.me; posting-host="4cad192d0203673fb726164e4e65e426"; logging-data="2305170"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/YtJ06Eis/PUdt/mdnLhSvHHkTmlAsw2w=" User-Agent: Mozilla/5.0 (X11; Linux i686; rv:52.0) Gecko/20100101 Firefox/52.0 SeaMonkey/2.49.4 Cancel-Lock: sha1:zyLZI8n00XY5ogVuQQyw1Neu+lE= In-Reply-To: Bytes: 3879 On 07/02/2024 10:05 AM, Janis Papanagnou wrote: > On 02.07.2024 16:40, Richard Owlett wrote: >> I have a Debian machine with Kate Version 16.08.3 . > > Disclaimer: I don't know the Kate editor. But I know Regular > Expressions (RE). > >> >> I wish to do a search & replace using regular expressions. >> The "Help" menu has led to >> https://docs.kde.org/stable5/en/kate/katepart/regular-expressions.html >> and >> https://docs.kde.org/stable5/en/kate/katepart/regex-patterns.html >> >> I have strings of the form "XYZn" where n is one to three digits >> representing values of from 1 to 299. I wish to replace all occurrences >> with "abc". > > You may do that with simple patterns if you don't have, say, > strings like XYZ300 that shall be disregarded. What I must avoid is it recognizing XYZ0 as a match. That would create chaos ;/ > Then the RE > may simply be XYZ[0-9]+ meaning any string XYZ that is > followed by an arbitrary number of digits. Instead you can > specify digits as optional XYZ[0-9][0-9]?[0-9]? or define > the amount of digits (1-3) explicitly XYZ[0-9]{1,3} which > still allows numbers out of range 1..299 (say, 0, 300) or > undesired syntaxes like 00 or 000. - Not sure it matters in > your case. If it matters, you can define alternatives with > a bar-symbol, e.g., XYZ([1-9]|[1-9][0-9]|[1-2][0-9][0-9]) > that you group with parenthesis. If Kate accepts XYZ([1-9]|[1-9][0-9]|[1-2][0-9][0-9]) as proper syntax, it should do what I was trying to specify. Having spent decades in QA/QC related tasks, I pay close attention to my first reference explicitly warning that Kate does not handle regular expressions exactly the same as some other editors. Hence the first lined of my post ;} > > Where you put such regular expressions in your Kate editor > is known to you, I suppose? Yes. There are some advantages to a GUI ;} In fact I just tried it. I gave it: > XYZ hello world > XYZ0 hello world > XYZ017 hello world > XYZ1 hello world > XYZ34 hello world > XYZ999 hello world It correctly replied: > XYZ hello world > XYZ0 hello world > XYZ017 hello world > abc hello world > abc hello world > abc9 hello world > >> >> The documents give essentially no examples. > > Regular expressions may first appear confusing, but the links > you posted actually has relevant examples. No problem with regular expressions per se. As my background was component level analog electronics, I ended up working for DEC in Power Supply Engineering in mid-70's. My intro to regular expressions was observing guys in adjacent department having fun with TECO. > >> >> Help please. >> TIA > > Hope that helps. IT DID! > > Janis >