• Re: Confused first time Kate user

    From candycanearter07@21:1/5 to Richard Owlett on Tue Jul 2 15:00:04 2024
    Richard Owlett <[email protected]> wrote at 14:40 this Tuesday (GMT):
    I have a Debian machine with Kate Version 16.08.3 .

    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".

    The documents give essentially no examples.

    Help please.
    TIA


    I'd recommend using an online regex generator like
    https://regex101.com/.

    This regex expression should do what you want:
    [[:digit:]]{3}
    --
    user <candycane> is generated from /dev/urandom

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Owlett@21:1/5 to All on Tue Jul 2 09:40:32 2024
    I have a Debian machine with Kate Version 16.08.3 .

    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".

    The documents give essentially no examples.

    Help please.
    TIA

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to All on Tue Jul 2 17:11:31 2024
    On 02.07.2024 17:00, candycanearter07 wrote:
    Richard Owlett <[email protected]> wrote at 14:40 this Tuesday (GMT):
    I have a Debian machine with Kate Version 16.08.3 .

    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".

    The documents give essentially no examples.

    Help please.
    TIA


    I'd recommend using an online regex generator like
    https://regex101.com/.

    This regex expression should do what you want:
    [[:digit:]]{3}

    Doesn't that mean _exactly_ 3 digits? (The OP wanted 1-299, which
    may be one up to three digits.) Some regexp parsers allow {,3} for
    an up-to range (but that might mean 0-3, thus also not the desired
    expression). Or you can explicitly specify the digits range {1,3}.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Richard Owlett on Tue Jul 2 17:05:40 2024
    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. 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.

    Where you put such regular expressions in your Kate editor
    is known to you, I suppose?


    The documents give essentially no examples.

    Regular expressions may first appear confusing, but the links
    you posted actually has relevant examples.


    Help please.
    TIA

    Hope that helps.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Owlett@21:1/5 to All on Wed Jul 3 06:15:14 2024
    On 07/02/2024 10:00 AM, candycanearter07 wrote:
    Richard Owlett <[email protected]> wrote at 14:40 this Tuesday (GMT):
    I have a Debian machine with Kate Version 16.08.3 .

    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".

    The documents give essentially no examples.

    Help please.
    TIA


    I'd recommend using an online regex generator like
    https://regex101.com/.

    Unusable as it responds:
    Unfortunately it seems your browser does not meet the criteria to
    properly render and utilize this website. You need a browser with
    support for web workers and Web Assembly.


    This regex expression should do what you want:
    [[:digit:]]{3}


    I suspect that would accept a value of "0".
    *ERROR* with results I don't wish to contemplate.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kenny McCormack@21:1/5 to [email protected] on Wed Jul 3 11:46:26 2024
    In article <v63bs4$25m5u$[email protected]>,
    Richard Owlett <[email protected]> wrote:
    ...
    This regex expression should do what you want:
    [[:digit:]]{3}


    I suspect that would accept a value of "0".
    *ERROR* with results I don't wish to contemplate.

    I suspect that what you want to do actually can't be done (accurately) with regexps, if we interpret your requirements literally. Most responders so
    far have pretty much glossed over your requirements. For example, while
    you want to match (and replace) XYZ299, you want to leave XYZ300 alone.

    You probably need a programming languages (such as AWK) to do this correctly.

    Note, BTW, that the real problem with regexps is that there are so many different implementations. Supposedly, there is a standard - actually, multiple standards - but each implementation is subtly different. For
    example, sometimes you need \ before special characters like ( or { or ?
    and sometimes you don't (depending on which implementation you are using).

    --
    "If our country is going broke, let it be from feeding the poor and caring for the elderly. And not from pampering the rich and fighting wars for them."

    --Living Blue in a Red State--

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Owlett@21:1/5 to Janis Papanagnou on Wed Jul 3 06:17:56 2024
    On 07/02/2024 10:11 AM, Janis Papanagnou wrote:
    On 02.07.2024 17:00, candycanearter07 wrote:
    Richard Owlett <[email protected]> wrote at 14:40 this Tuesday (GMT):
    I have a Debian machine with Kate Version 16.08.3 .

    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".

    The documents give essentially no examples.

    Help please.
    TIA


    I'd recommend using an online regex generator like
    https://regex101.com/.

    This regex expression should do what you want:
    [[:digit:]]{3}

    Doesn't that mean _exactly_ 3 digits? (The OP wanted 1-299, which
    may be one up to three digits.) Some regexp parsers allow {,3} for
    an up-to range (but that might mean 0-3, thus also not the desired expression). Or you can explicitly specify the digits range {1,3}.

    Janis


    You correctly interpreted the restrictions I have.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Owlett@21:1/5 to Kenny McCormack on Wed Jul 3 07:45:18 2024
    On 07/03/2024 06:46 AM, Kenny McCormack wrote:
    In article <v63bs4$25m5u$[email protected]>,
    Richard Owlett <[email protected]> wrote:
    ...
    This regex expression should do what you want:
    [[:digit:]]{3}


    I suspect that would accept a value of "0".
    *ERROR* with results I don't wish to contemplate.

    I suspect that what you want to do actually can't be done (accurately) with regexps, if we interpret your requirements literally. Most responders so
    far have pretty much glossed over your requirements.

    You noticed < *GRIN* >
    Unfortunately that's fairly common on USENET.
    I'm used to windowing "wheat" from "chaff".

    For example, while
    you want to match (and replace) XYZ299, you want to leave XYZ300 alone.

    Actually its more the case that for _my_ application XYZ300 and above physically cannot exist.


    You probably need a programming languages (such as AWK) to do this correctly.

    No. Further in this thread Janis Papanagnou demonstrated what I needed.


    Note, BTW, that the real problem with regexps is that there are so many different implementations. Supposedly, there is a standard - actually, multiple standards - but each implementation is subtly different. For example, sometimes you need \ before special characters like ( or { or ?
    and sometimes you don't (depending on which implementation you are using).


    Yepp.
    That's why my "Subject:" AND first sentence explicitly reference Kate.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Owlett@21:1/5 to Janis Papanagnou on Wed Jul 3 07:22:14 2024
    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


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From candycanearter07@21:1/5 to Janis Papanagnou on Wed Jul 3 13:30:03 2024
    Janis Papanagnou <[email protected]> wrote at 15:11 this Tuesday (GMT):
    On 02.07.2024 17:00, candycanearter07 wrote:
    Richard Owlett <[email protected]> wrote at 14:40 this Tuesday (GMT):
    I have a Debian machine with Kate Version 16.08.3 .

    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".

    The documents give essentially no examples.

    Help please.
    TIA


    I'd recommend using an online regex generator like
    https://regex101.com/.

    This regex expression should do what you want:
    [[:digit:]]{3}

    Doesn't that mean _exactly_ 3 digits? (The OP wanted 1-299, which
    may be one up to three digits.) Some regexp parsers allow {,3} for
    an up-to range (but that might mean 0-3, thus also not the desired expression). Or you can explicitly specify the digits range {1,3}.

    Janis


    Ah right, sorry. I don't use regex that frequently.
    --
    user <candycane> is generated from /dev/urandom

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Owlett@21:1/5 to Janis Papanagnou on Wed Jul 3 13:47:04 2024
    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. 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.

    Where you put such regular expressions in your Kate editor
    is known to you, I suppose?


    The documents give essentially no examples.

    Regular expressions may first appear confusing, but the links
    you posted actually has relevant examples.


    Help please.
    TIA

    Hope that helps.

    Janis


    The GUI version of Kate accepts XYZ([1-9]|[1-9][0-9]|[1-2][0-9][0-9])
    with no problem.

    I tried out on a real world test.

    I'm converting a paragraph formatted KJV Bible [1][2] to a pleasant
    reading experience for vision impaired seniors who have minimal computer experience.

    The search string below worked fine {unexpectedly, didn't have to escape
    any non-alphanumeric characters}
    <span class="verse" id="V([1-9]|[1-9][0-9]|[1-2][0-9][0-9])"

    Kate had other useful features. I recognized a HTML construct that I
    hadn't considered. I didn't show as a problem in my test browser. But
    could have in another scenario. It can also do things in command line
    mode. That should ease the task of processing >1000 text chapters automatically. Guess I spend the rest of the day reading documentation :}

    Thank you

    This is a resend - original reply did not appear





    [1] KJV Cambridge Paragraph Bible <https://ebible.org/engkjvcpb/>
    [2] <https://ebible.org/Scriptures/engkjvcpb_html.zip>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)