• Confused first time Kate user

    From Richard Owlett@rowlett@access.net to comp.editors on Tue Jul 2 09:40:32 2024
    From Newsgroup: comp.editors

    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

    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From candycanearter07@candycanearter07@candycanearter07.nomail.afraid to comp.editors on Tue Jul 2 15:00:04 2024
    From Newsgroup: comp.editors

    Richard Owlett <rowlett@access.net> 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
    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.editors on Tue Jul 2 17:05:40 2024
    From Newsgroup: comp.editors

    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

    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.editors on Tue Jul 2 17:11:31 2024
    From Newsgroup: comp.editors

    On 02.07.2024 17:00, candycanearter07 wrote:
    Richard Owlett <rowlett@access.net> 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

    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From Richard Owlett@rowlett@access.net to comp.editors on Wed Jul 3 05:57:39 2024
    From Newsgroup: comp.editors

    On 07/02/2024 09:40 AM, Richard Owlett wrote:
    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


    The first paragraph of the first reference explicitly warns:
    This Appendix contains a brief but hopefully sufficient and
    covering introduction to the world of regular
    expressions. It documents regular expressions in the form
    available within KatePart, which is not compatible with the regular expressions of perl, nor with those of for example
    grep.

    Please note the phrasing "... which is not compatible ...".
    This is a personal project. I started searching the web for information
    on regular expressions. Circumstances require I use this particular
    machine with its current software ] no updates ;[

    My formal background is limited to a single introductory programming
    course I took as a freshman E.E. student in '61. I learned by doing.

    My web reading and a discussion in another forum has may has made me
    aware that there is more than one way to handle regular expressions.

    This time I asked on a "editor" focused group and specified the specific editor I'm using.


    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From Richard Owlett@rowlett@access.net to comp.editors on Wed Jul 3 06:15:14 2024
    From Newsgroup: comp.editors

    On 07/02/2024 10:00 AM, candycanearter07 wrote:
    Richard Owlett <rowlett@access.net> 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.


    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From Richard Owlett@rowlett@access.net to comp.editors on Wed Jul 3 06:17:56 2024
    From Newsgroup: comp.editors

    On 07/02/2024 10:11 AM, Janis Papanagnou wrote:
    On 02.07.2024 17:00, candycanearter07 wrote:
    Richard Owlett <rowlett@access.net> 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.


    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From gazelle@gazelle@shell.xmission.com (Kenny McCormack) to comp.editors on Wed Jul 3 11:46:26 2024
    From Newsgroup: comp.editors

    In article <v63bs4$25m5u$1@dont-email.me>,
    Richard Owlett <rowlett@access.net> 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--
    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From Richard Owlett@rowlett@access.net to comp.editors on Wed Jul 3 07:22:14 2024
    From Newsgroup: comp.editors

    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


    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From Richard Owlett@rowlett@access.net to comp.editors on Wed Jul 3 07:45:18 2024
    From Newsgroup: comp.editors

    On 07/03/2024 06:46 AM, Kenny McCormack wrote:
    In article <v63bs4$25m5u$1@dont-email.me>,
    Richard Owlett <rowlett@access.net> 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.




    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From candycanearter07@candycanearter07@candycanearter07.nomail.afraid to comp.editors on Wed Jul 3 13:30:03 2024
    From Newsgroup: comp.editors

    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote at 15:11 this Tuesday (GMT):
    On 02.07.2024 17:00, candycanearter07 wrote:
    Richard Owlett <rowlett@access.net> 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
    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From Richard Owlett@rowlett@access.net to comp.editors on Wed Jul 3 13:47:04 2024
    From Newsgroup: comp.editors

    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>
    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.editors on Fri Jul 5 01:05:08 2024
    From Newsgroup: comp.editors

    On Wed, 3 Jul 2024 05:57:39 -0500, Richard Owlett wrote:

    My web reading and a discussion in another forum has may has made me
    aware that there is more than one way to handle regular expressions.

    The Perl style seems to have become something of a de-facto standard.
    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.editors on Fri Jul 5 04:00:01 2024
    From Newsgroup: comp.editors

    On 05.07.2024 03:05, Lawrence D'Oliveiro wrote:
    On Wed, 3 Jul 2024 05:57:39 -0500, Richard Owlett wrote:

    My web reading and a discussion in another forum has may has made me
    aware that there is more than one way to handle regular expressions.

    I'm not quite sure what you mean by "handle" REs. There's tools
    with different syntax and that support more or less functions,
    even sometimes exceeding the class of a Regular grammar (at a
    given cost). - I suppose you meant this?


    The Perl style seems to have become something of a de-facto standard.

    Hardly. First, there's differences on the functional level; Perl
    supports with their regexp library functions that are not part
    of the Regular Expression grammar class, they exceed that class.
    The consequence is that for that subset there's no O(N) (linear)
    complexity guaranteed any more.
    Second, there's syntactical differences between tools, that are
    necessary to handle meta-characters in their specific language
    context; in one tool meta-characters need, e.g., to be escaped
    where in another context that's not necessary. How can something
    be a standard when (standard-)tools do not support that.
    Then there's sometimes syntactical convenience shortcuts in use
    (here I'm thinking of Perl's escaped classes of common entities
    and their negated forms); these are very handy especially where
    these expressions get more complex.

    Moreover, when speaking about [de facto] "standards"; what would
    that mean in the light of existing (real) standards, like POSIX,
    that define behavior of tools and the supported RE implementation
    (BRE, ERE).
    And finally shells (like Kornshell) that had since 1988 version
    an own syntax (not comparable with BRE, ERE, Perl's, syntax), an
    extension of the "wildcard" patterns. Also back-references, one
    extension that doesn't guaranteed O(N) any more, had been added
    later. Only later version supported the ERE syntax in addition
    to the original Ksh-"patterns".

    It's know that fans of specific products often use terms like
    de-facto standard. Readers should be careful when spotting such
    phrases, they are often nothing but marketing talk.

    Usually you have requirements and have to make yourself familiar
    with what the allowed tool chest supports (including the Regexp
    facilities). Granted, getting familiar is harder than following
    marketing suggestions. But there's (real) standards (as opposed
    to "de-facto" standards), so if you're learning the standards
    (RE oder otherwise) you may apply these in a broader context.

    And if you have the time and the tools that support these "Perl
    regexps", yet better, since they make some things appear tidier
    and add convenient functional extensions. Note that Perl regexps
    also follow (and extend) the basic syntax of the other standard
    Regexps mentioned (BRE, ERE), so learning the basics first can
    never be wrong.

    Janis

    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.editors on Fri Jul 5 03:58:00 2024
    From Newsgroup: comp.editors

    On Fri, 5 Jul 2024 04:00:01 +0200, Janis Papanagnou wrote:

    On 05.07.2024 03:05, Lawrence D'Oliveiro wrote:

    The Perl style seems to have become something of a de-facto standard.

    Hardly. First, there's differences on the functional level; Perl
    supports with their regexp library functions that are not part of the
    Regular Expression grammar class, they exceed that class. The
    consequence is that for that subset there's no O(N) (linear) complexity guaranteed any more.

    Precisely. Many users of REs seem to feel it is useful to at least
    have the option of such extensions, and they are willing to pay that
    price.

    Second, there's syntactical differences between tools, that are
    necessary to handle meta-characters in their specific language
    context; in one tool meta-characters need, e.g., to be escaped where
    in another context that's not necessary. How can something be a
    standard when (standard-)tools do not support that.

    Surely they do it the way that Perl does. Hence rCLPerl stylerCY.

    Moreover, when speaking about [de facto] "standards"; what would
    that mean in the light of existing (real) standards ...

    It means there is a standard library (actually a whole bunch of them)
    you can link against to immediately support that style of regular
    expression.

    <https://packages.debian.org/search?keywords=pcre&searchon=names&suite=stable&section=all>
    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.editors on Sat Jul 6 02:53:07 2024
    From Newsgroup: comp.editors

    On 05.07.2024 05:58, Lawrence D'Oliveiro wrote:
    On Fri, 5 Jul 2024 04:00:01 +0200, Janis Papanagnou wrote:

    [...] First, there's differences on the functional level; Perl
    supports with their regexp library functions that are not part of the
    Regular Expression grammar class, they exceed that class. The
    consequence is that for that subset there's no O(N) (linear) complexity
    guaranteed any more.

    Precisely. Many users of REs seem to feel it is useful to at least
    have the option of such extensions, and they are willing to pay that
    price.

    There's two problems; one related to the Perl user, and one related
    to the Perl implementor - if they're not aware about the line drawn
    between regular and non-regular grammars. - The Perl user should be
    informed about the complexities they buy with certain constructs
    so that they are really "willing to pay" and not "pay a price that
    they just did not expect". The implementor shall be aware that the
    mechanism implemented should well differentiate between the two
    domains of complexity for the respective functions, otherwise (as
    happened in the past!) a common mechanism is implemented that even
    for ordinary O(N) Regular Expressions non-linear complexities have
    to be payed (unintentionally!) in certain, even simple, cases.

    Note that this caveat is not Perl-specific; all pattern matchers
    that support such functions, like e.g. back-references, should be
    aware of that.

    Janis

    --- Synchronet 3.21b-Linux NewsLink 1.2