Liste des Groupes | Revenir à c editors |
On 02.07.2024 16:40, Richard Owlett wrote:What I must avoid is it recognizing XYZ0 as a match.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).
>You may do that with simple patterns if you don't have, say,
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".
strings like XYZ300 that shall be disregarded.
Then the REIf 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.
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 editorYes. There are some advantages to a GUI ;}
is known to you, I suppose?
XYZ hello worldIt correctly replied:
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
No problem with regular expressions per se.>Regular expressions may first appear confusing, but the links
The documents give essentially no examples.
you posted actually has relevant examples.
IT DID!>Hope that helps.
Help please.
TIA
Janis
Les messages affichés proviennent d'usenet.