I want to delete a line that is between two characters, as well as the characters themselves, say, for example:
I want to replace the entire string between "#?" and ";" and delete it with characters.
From this
"this #?anystring; is #?anystring2jk; test"
For this
"this is test"
how can i do this in java?
Use regex:
myString.replaceAll("#\?.*?;", "");
@computerish your answer is failing in Java. The modified version works.
myString.replaceAll("#\\?.*?;", "");
? , JVM escape-. ? , . () , .
string.replaceAll(start+".*"+end, "")
is a simple starting point. You may have to deal with the greediness of regex operators.
Source: https://habr.com/ru/post/1765736/More articles:Simple OpenGL code always causes a segmentation error (C ++ on Ubuntu, virtual machine) - c ++Garbled Text in uniqueidentifier in SQLite - .netSerializing objects and deserializing when changing a class field - javaHow to bulk Insert csv with double quotes around all values? - sql-serverHelp filling out the "info.plist" file - iphoneSize Struct, check 64-bit or 32-bit - c #PHP: foreach variable assignment and links: how to do it? - loopsWill Apple reject my application to use setStatusBarOrientation? - iphoneПочему файлы в моей папке NSBundle для iPhone не удаляются? - fileConfiguring SESSION Logged Data - Security? - securityAll Articles