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 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
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}
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
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.
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/.
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}
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
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.
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?
XYZ hello world
XYZ0 hello world
XYZ017 hello world
XYZ1 hello world
XYZ34 hello world
XYZ999 hello world
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.
Help please.
TIA
Hope that helps.
Janis
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).
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
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
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.
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.
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.
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.
Moreover, when speaking about [de facto] "standards"; what would
that mean in the light of existing (real) standards ...
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.
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 59 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 00:16:51 |
| Calls: | 810 |
| Files: | 1,287 |
| Messages: | 197,579 |