Here is my example file :
lineone one
RUN lineone two
lineone three
RUN lineone four
I want to select all lines not starting with run, here is how I did it :
^([^RUN])
Is it possible to match all lines not starting with RUN and then append them to the back of the previous line ? like this
lineone one RUN lineone two
lineone three RUN lineone four
If your example is correct you just need to replace "\nRUN" with " RUN".
System.out.println(yourString.replaceAll("\nRUN", " RUN"));
Result:
lineone one RUN lineone two lineone three RUN lineone four
ideone
use str.startsWith("RUN");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With