Outbreaker Posted August 13, 2023 Posted August 13, 2023 Hi, Dose someone know how to find the first occurrence of [SourceNames.x86] in a text file and then add a new text line under it?
jaclaz Posted August 13, 2023 Posted August 13, 2023 What has RegEx to do with this? You are looking for a very definite text, you can use gsar for this: http://tjaberg.com/ or FART: https://fart-it.sourceforge.net/ Otherwise you might want to try using SED (much more powerful but not as easy to use), a windows port is here: https://github.com/mbuilov/sed-windows A number of other tools/utilities do exist, but - generally speaking - they won't manage gracefully the CR+LF (the one after the [SourceNames.x86]). jaclaz
Outbreaker Posted August 13, 2023 Author Posted August 13, 2023 (edited) I have to use the "JREPL.bat" tool. All other tools have problems with different text encodings. This works: JREPL.BAT "[SourceNames.x86]" "[SourceNames.x86]\r\nNew-Line" /XSEQ /L /f "File.txt" /o - But i try to do something like this: JREPL.BAT "(RegEx)[SourceNames.x86]\r\n(RegEx)" "Test-Line" /XSEQ /L /f "File.txt" /o - Edited August 13, 2023 by Outbreaker
jaclaz Posted August 13, 2023 Posted August 13, 2023 I do not understand your question, then, maybe it is a moving one. You seemingly asked a question about a problem that you already solved, both the question and the solution you found do not need the use of RegEx expression. Unfortunately I cannot follow you on the "I have to use" and "All other tools". If you have to use JREPL.BAT, it has a dedicated thread on another forum, ask your questions here: https://www.dostips.com/forum/viewtopic.php?t=6044 it is much more likely to find there people familiar with that tool. RegEx is already - by itself - complex enough, the ways each and every tool implements it may (or may not) be non-standard. TIme for a distraction: https://xkcd.com/1171/ jaclaz
Outbreaker Posted August 16, 2023 Author Posted August 16, 2023 (edited) I now found the RegEx solution for it. JREPL.BAT "\[SourceNames\.x86\]" "$&\r\nTest-Line" /XSEQ /f "File.txt" /o - Edited August 16, 2023 by Outbreaker
jaclaz Posted August 16, 2023 Posted August 16, 2023 25 minutes ago, Outbreaker said: I now found the RegEx solution for it. Though it doesn't seem at all like there is a RegEx expression anywhere in that. Anyway, the only important thing is that you are happy with your solution. jaclaz
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now