Hi,

here i just try to delete the content in text file between S and e letter.
but i don't know to write the ReplaceAll() methode after this

String[] paras = Pattern.compile("^(S)(.*)(e)$").split(inputText);

How could i use ReplaceAll() here?

Thank you

So you're using this pattern to split on - doesn't that eliminate anything that matches the pattern? If I split "a+b+c" on "+", I get ["a", "b", "c"] - what happens when you run this on

Anyone
Someone
Something
Somebody
Science
Some other word


I would expect

["Anyone","Something","Somebody","Some other word"]

based on the behavior of split in other contexts.

Also, this pattern should find only lines starting with "S" and ending with "e", so "Someone" would match, but "Somebody" would not, I think.
You would want "Something" and "winSome" and "handSomely" to match, I think. If so, remove the anchors. Then you're going to have to deal with greedy/non-greedy matching. I believe greedy matching is usually the default, so "'Stop eating', Said he to Sue" would match once, on the whole string, but you'd want it to match three times.

Sorry this isn't very organized, but it's the end of the day, and I'm going home. Good luck, hope it helps a little.

OK thank you Jon take a rest.
i will read your answer carefully.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.